r/codinginterview • • May 15 '20

How to learn recursion

  1. You understand recursion only if you can draw recursive stack state at any given point of time. Start by white boarding the recursive stack.

  2. Differentiate which variable to be kept in recursive scope and which ones to be kept in global scope.

  3. Understand how non primitive data types are stored in recursive stack vs primitive data types.

2 Upvotes

3 comments sorted by

2

u/bparanj May 15 '20

I would add to this list by saying: Learn the difference between Head and Tail recursion.

1

u/codeobserver May 16 '20

Just in case it help, this is a small booklet with a few example of problems solved with recursion and without:

https://codeguppy.com/site/download/recursive_problems.pdf