Computational complexity of Fibonacci Sequence

后端 未结 11 1591
慢半拍i
慢半拍i 2020-11-21 10:27

I understand Big-O notation, but I don\'t know how to calculate it for many functions. In particular, I\'ve been trying to figure out the computational complexity of the nai

11条回答
  •  孤城傲影
    2020-11-21 10:51

    You can expand it and have a visulization

         T(n) = T(n-1) + T(n-2) <
         T(n-1) + T(n-1) 
    
         = 2*T(n-1)   
         = 2*2*T(n-2)
         = 2*2*2*T(n-3)
         ....
         = 2^i*T(n-i)
         ...
         ==> O(2^n)
    

提交回复
热议问题