Hacker News new | past | comments | ask | show | jobs | submit login

1. The worst case for fibonacci is not exponential, it's actually O(fib(n)).

2. The recursive function `fib_helper` in TFA is actually iterative in an TCO environment. Read it closely. There's only on recursive call at the end, not two. `back_one` and `back_two` mean fib(x-1) and fib(x-2) respectively, the same way you would solve it with a loop. With the right `CFLAGS` it should produce more or less the same bytecode.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: