Divide and Conquer Paradigm Flashcards
Describe the three steps that the divide and conquer paradigm divides recursion into
- Divide* the problems into sub problems of the same problem - D(n)
- Conquer* each subproblem. Solve either recursively or not - aT(n)
- Combine* the solutions into an overall solution - C(n)
What is recurrence
An equation or inequality that describes a function in terms of ites value on smaller functions
what is the recurrence equation of merge sort
c if n = 1
2T(n/2) + cn n>1
what is the recurrence equation of factorial
c if n = 1
T(n-1) + c n>1
what is the recurrence equation of binary search
c if n = 1
T(n/2) + c n>1
describe the substitution method to solve recurrences
make a good guess.
- guess the form of the answer
- use induction to find constants
- show the solution works.
describe the iteration method to solve recurrences
- expand the recurrence
- work out the algebra to express as a sum
- evaluate the sum
describe the master method to solve recurrences
T(n) = a T(n/b) + f(n)
- find a b and f(n)
- calculate n^(log_b a)
- how does f(n) relate to the above
give the three different cases in the master method
O(n^log_b a) if f(n) = O(n^(log_b a - constant)) O(n^(log_b a) log n) if f(n) = O(n^log_b a) O(f(n)) if f(n) = O(n^(log_b a) + constant)) and af(n/b) <= cf(n) for large n