Stop tracing, start trusting
Most students try to understand recursion by tracing every call on paper. That works for depth 3 and collapses at depth 10. It is the wrong tool.
The right method has three steps.
- Write the base case. The input so small the answer is obvious.
- Assume the function already works for any smaller input. Do not
justify this. Assume it.
- Use that assumption to solve the current input, and make sure your
recursive call is on something strictly smaller.
If all three hold, the function is correct. This is induction, the same proof technique from your discrete mathematics paper.
Applying the method
Sum of an array.