Divide and Conquer
T(n) = aT(n/b) + f(n)
the Master theorem
the max number of compares to mergesort of a list of size <= n
what does T(n) represent in a mergesort recurrence?
to generalize divide and conquer algorithms where subproblems have substantially different sizes
what is the role of the Akra-Bazzi theorem?
O(n^1.585)
How many bit operations does Karatsuba's algorithm need to multiply two n-bit integers?
mergesort
A sort that divides the list into two parts, sorts those parts, and then brings the sorted parts back together.
a >= 1, number of subproblems b > 0, factor by which the subproblem decreases f(n), the work/time spent on each subproblem
Define the variables in the master theorem: T(n) = aT(n/b) + f(n)
Θ(n) and Θ(n^3) respectfully
What are the run time of the gradeschool dot-product and matrix multiplication algorithms?
case 1) total cost dominated by cost of leaves (r>1) case 2) total cost evenly distributed among levels (r=1) case 3) total cost is dominated by the cost of the root (r<1)
What are the three cases for the return of the Master theorem?
(Case 1) if f(n) = Θ(n^(k-e)) some constant e, then T(n) = Θ(n^k) Case 2) if f(n) = Θ(n^k log^p(n)), then T(n) = Θ(n^k log^(p+1) n) Case 3) if f(n) = Ω(n^(k+e)) some constant e>0, and if af(n/b) <= cf(n) for some constant c<1, and all n are sufficiently large, then T(n) = Θ(f(n))
What do these cases look like formulaically? case 1) total cost dominated by cost of leaves (r>1) case 2) total cost evenly distributed among levels (r=1) case 3) total cost is dominated by the cost of the root (r<1)
divide the problem into subproblems that are similar to the original but smaller in size solve the subproblems recursively (if they are small enough, solve them in a straightforward manner) combine the solutions to create the solution to the larger problem
What is the main idea of a divide and conquer algorithm?
T(n) = Θ(nlogn) (divide=Θ(1), conquer=2T(n/2), combine=Θ(n))
What is the running time of mergesort?
O(n^2.81)
What is the runtime of Strassen's Trick for multiplying two matrices?
k = log(sub b)(n) levels a^i = number of subproblems at level i n/b^i = size of subproblem at level i
define the components of a recursion tree (k, a^i, n/b^i)