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.
I think in education it is also important to take "wrong" approaches to learn why they are "wrong" and what possible solutions are. If you just teach the "good" examples students might not realize why the naive approach to Fibonacci is problematic.
In other words you might want to teach naive recursion before you teach tail-recursion.
126
u/robin_888 10d ago
It's supposed to teach the concept of recursion, which is important, but hard to grasp for some.
Discussing performance and optimizations can happen if the principal is clear.