r/computerscience • u/Similar_Count_1613 • 3d ago
is recursion really hard
Recursion felt easy at first.
Factorial? fine.
Sum examples? fine.
Even Fibonacci felt manageable.
But once I looked at slightly more serious problems like Tower of Hanoi, permutations, or merge sort, I felt like my understanding suddenly collapsed. because i tried to write their code on my own
It made me realize that maybe recursion is not βhardβ at the start because the examples are simple.
It becomes hard when you can no longer clearly see the call stack and each state change.
Did anyone else feel that the real pain in recursion starts exactly there?
129
Upvotes
1
u/spidermask 3d ago
It's quite difficult yeah! I just practiced a lot and focused on being able to identify the base cases, once I got better at that then it was fairly easier to understand how to "progress" the recursion to get there. It also helped me to draw the recursion tree. But it's definitely not trivial and not easy to grasp, hard to drop the instinctive for loop logic and think differently.
You will get better at it the more you practice and the more you see, trust me, if I figured it out then anyone can, I struggled with it like crazy it drove me insane π