问题
This is a problem from my textbook. The Collatz conjecture (or the "3n + 1" problem) works as follows (given some natural number n):
while n > 1 do
if n is even then
n = n / 2
else
n = 3n + 1
end if
end while
I've skimmed a few papers on the conjecture but they all went over my head. I'm trying to get a basic understanding of the algorithm's complexity. Is it possible to comment on an upper or lower bound for the number of operations performed (in the worst case)?
The only thing I've been able to deduce is that a best-case input must be of the form n = 2^k (which will result in the fewest ops). From this, is it fair to say that the worst-case input is any non power of two?
I've been struggling with trying to conceptualize a rough upper or lower bound. For any n, it seems as if there is too much switching from odd to even (which results in increasing by a factor of 3 or reducing by a factor of 2) to comment on the least/most amount of calculations performed.
Any help is appreciated.
回答1:
Building off of @Kevin's comment: Right now, we are not even sure that this process terminates for all inputs. It's quite possible that the sequence always terminates, and it's quite possible that there are inputs for which the sequence never terminates.
In the case where the sequence never terminates for certain inputs, then the worst-case inputs would be any number where the sequence never stops. This isn't necessarily the same as "any non-power-of-two," since there are many non-powers-of-two that we know of for which the sequence converges (say, for example, 15).
In the case where the sequence always terminates for all inputs, we would have to look more closely at why that's the case in order to determine what the "worst-case" inputs would be. It is unlikely that all non-powers-of-two would be worst-case inputs. Chances are that there will be an infinite family of natural numbers that form worst-case inputs for numbers around their size, similarly to how the Fibonacci numbers give worst-case inputs to Euclid's algorithm.
Of course, none of this is known right now - that's the beauty of working with open problems!
Hope this helps!
来源:https://stackoverflow.com/questions/16905529/collatz-conjecture-loose-upper-lower-bounds