General workflow to solve a recursion problem
- Define the recursion function;
- Write down the recurrence relation and base case;
- Use memoization to eliminate the duplicate calculation problem, if it exists.
- Whenever possible, implement the function as tail recursion, to optimize the space complexity.
Comments
Post a Comment