|
CS 3343 Analysis of Algorithms Fall 2012 Recitation 14 Final Review Partial Answers |
Recurrences, solution by Master Method | |||||||
---|---|---|---|---|---|---|---|
Recurrence | a | b | logb(a) | nlogb(a) | f(n) | Case | Behavior |
a. T(n) = 64 T(n / 4) + √n | 64 | 4 | log4(64) = 3 | n3 | n0.5 | 1 | Θ(n3) |
b. T(n) = 9 T(n / 3) + n2 log(n) | 9 | 3 | log3(9) = 2 | n2 | n2 log(n) | none | Master fails |
c. T(n) = 16 T(n / 4) + n4 | 16 | 4 | log4(16) = 2 | n2 | n4 | 3 | Θ(n4) |
d. T(n) = 2 T(n / 4) + √n | 2 | 4 | log4(2) = 1/2 | n1/2 = √n | √n | 2 | Θ(√n log(n)) |
|
|
Subset-Sum Problem (SS): Start with a set A of positive integers and a desired sum S. The decision question: Is there a subset A' of A such that sum( a | a in A' ) = S? |
Partition Problem (PART): Start with a set A of positive integers. The decision question: Is there a subset A' of A such that sum( a | a in A' ) = sum( a | a in A - A' )? [Here A - A' is the complement of A' in A.] |
|
|