Skip to content

Latest commit

 

History

History

README.md

Recursion

Goal: Use Python recursively.

Overview

What is Recursion?

There are two main instances of recursion.

  • The first is when recursion is used as a technique in which a function makes one or more calls to itself.
  • The second is when a data structure uses smaller instances of the exact same type of data structure when it represents itself.

Why use Recursion?

Recursion provides a powerful alternative for performing repetitions of tasks in which a loop is not ideal. Whenever you are trying to develop a recursive solution it is very important to think about the base case, as your solution will need to return the base case once all the recursive cases have been worked through.

Memoization

Memoization effectively refers to remembering ("memoization" -> "memorandum" -> to be remembered) results of method calls based on the method inputs and then returning the rememebred result rather than computing the result again. You can think of it as cache for method results. We'll use this in some of the interview problems as improved versions of a purely recursive solution.

Practice Problems

  • [Permute Array of Unique Integers]

  • [Letter Case Permutation]

  • [N Choose K Combinations]

  • [Permute Array Of Integers Duplicates Allowed]

  • [Subsets With Duplicate Characters]

  • [Words From Phone Number]

  • [Generate All Combinations With Sum Equal To Target]

  • [Generate All Subset Of A Set]

  • [Palindromic Decomposition Of A String]

  • [How Many Binary Search Trees With n Nodes]

  • [Solve Sudoku Puzzle]

  • [n Queen Problem]

  • [Generate All Possible Expressions That Evaluate to The Given Target Value]

  • [Possible To Achieve Target Sum]

  • [Find All Well Formed Brackets]

  • Factorial

  • Fibonacci

  • Cumulative Sum

  • Summation

  • Reverse String

  • String Permutation

  • Coin Change

  • Product Sum

  • Permutations

  • Powerset

  • Phone Number Mnemonics

  • [Staircase Traversal]

  • [Lowest Common Manager]

  • [Interweaving Strings]

  • [Solve Sudoku]

  • [Generate Div Tags]

  • [Ambigiuous Measurements]

  • [Number of Binary Tree Topology]

  • [Non-Attacking Queens]

See Also

Recursion