In order to calculate number n in the Fibonacci sequence, I had an assignment in school last week to implement the function. A 'sub-assignment' was to apply it to o (n) time to the complexity of the accumulation (can not be a correct translation) unless I tried to create the function (int -> integer) All worked fine. Using a little bit I realized that the complexity of time for the large number was really close to the O (N ^ 2). It is for me that this integer should be due to implementation, which is how it works. Makes a little curious. I searched for some Google searches and did not get anything that was useful, so I'm changing you in the hope of adding an explanation or a link that tells it well.
My code:
ackfib 0 = 0 ackfib 1 = 1 ackfib n = loop n 1 0 1 where loop n n1 n2 i. I & lt; N = Loop N (N1 + N2) N1 (I + 1). I == N = N1 | I & gt; Victor
It is actually from Haskell There is nothing to do with it, it is only a result of the fact that Fibonacci numbers are increasing rapidly, especially about NO Fibonacci numbers (Log 2 & phi;} n or approximately 0.48 N bits where & phi; is the golden ratio (1 + sqrt 5) / 2. In addition to the k-bit integer takes time (o), in addition to your O (n) actually o (n ^ 2) the total of time Take the numbers, why On average,
(Note to the Stickles: Big O really should have a big theta.)
< / Html>
Comments
Post a Comment