ASIDE: today, I am so tired, but I decided to write one to stick to it. However, the question is so watery that you can entertain yourself!
[Topic] A step has a total of N levels. A jump can take the first or second order. This section describes the total number of medium hops and analyzes the time complexity.
[Thinking path] from special to general ideas. If there is only one level, there is only one method of jumping. If there is one level 2, so there is a 2 middle hop method (skip level 1 and then skip level 1, and then skip level 2 at a time). What if there is level n? Suppose we have the Skip method in F (n) for the Level n step. In Order N, we consider that if the first hop has two options: the first hop has the Level 1, the rest of the n-1 order has F (n-1) Jump method; the first jump level 2, The Rest Of The N-2 order F (n-2) Jump method, then the total number of hops is F (n-1) + f (n-2 ). Here we can see that this is the recursive formula of the Fibonacci series, but the first two items are slightly different. The written mathematical expressions are as follows:
For the specific Fibonacci sequenceCodeAndAlgorithmIn [algorithm 02], we have discussed the time complexity analysis in great detail and will not go into details. If you are interested, you can go back and take a look.
Note:
1) Compile all the code environments in this blogWin7 + vc6. All code has been debugged by the blogger.
2) BloggerPython27This blogArticleCopyright. For Network reprinting, please indicate the sourceHttp://www.cnblogs.com/python27/. You have any suggestions for solving the problem. Please feel free to comment on them.