Re:Data structures and algorithms I actually used while work...
by throwawayiionqz on Wednesday July 15, 2020 @07:22AM
(#23843683)
The "better" recursive solution computes fib(n) and fib(n-1) at the same time. Linear time recursion!
[ Parent
| on HN ]
Re:Data structures and algorithms I actually used while work...
by dotancohen on Wednesday July 15, 2020 @07:30AM
(#23843741)
You have a bug for the case of fib(0).
Re:Data structures and algorithms I actually used while work...
by throwawayiionqz on Wednesday July 15, 2020 @07:34AM
(#23843771)
Indeed, if you wish the sequence to be defined at 0, eru's solution is better (and appeared earlier while I was typing)