Recursion and Dynamic Programming Flashcards

1
Q

What is recursive?

A

Recursive solutions are built off of solutions to subproblems. You might add, delete or change the previous solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bottom-Up Approach

A

Start with how to solve a simple case, i.g: list with one element [1], then figure out [1,2], then [1,2,3], then [1,2,3,4]….So, the solution can be found from the previous case/multiple previous case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Top-Down Approach

A
  • Memoization
  • How to divide the problem for case N to subproblems
  • Be careful about the overlap of the cases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Half-n-Half Approach

A
  • Binary Search: i.g. Looking for an element in a sorted array, we check in the first half, and then recurse look at the other half to see if that array contains the value
  • Merge Sort: Sort each half of the array and merge together
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Recursive vs Iterative Solutions

A
  • Each recursive call adds a new layer to the stack. If the algorithm recurses to a depth of n, it uses at least O(n) memory.
  • Implement recursive algorithm iteratively.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly