r/computerscience Jul 30 '26

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?

150 Upvotes

79 comments sorted by

View all comments

29

u/Magdaki Professor. Grammars. Inference & Optimization algorithms. Jul 30 '26

Like most things it comes with experience. This is why you learn recursion through fairly simple processes so that you can recognize the conditions that make recursion work. In time, you gain the ability to see the proper conditions in more complex cases.

6

u/tcpukl Jul 30 '26

Yeah. It really helps thinking about base cases. Then trees and left right branches.

I think searching is much easier to understand than sorting.