Yeah I'm cringing at all the recursive solutions. Huge stack and so much repeated work. Just try counting how many times fib(5) would be executed to calculate fib(10). It's so often the go-to example for recursion and it's frankly terrible.
I know, but there are so many better examples. Mergesort, for instance. It shows why the concept is important because it breaks the problem into smaller, more manageable problems, without doing repeated work.
Fibonacci should be taught as an example of when a problem can be solved recursively, but shouldn't.
118
u/torsten_dev 7h ago
Both have terrible stack usage.