280 likes | 415 Views
Lecture 4 Divide-and-Conquer. What’s Self-Reducibility?. A problem can be reduced to several “same” problems with smaller inputs. Divide and Conquer. Divide the problem into subproblems. Conquer the subproblems by solving them recursively.
E N D
What’s Self-Reducibility? • A problem can be reduced to several “same” problems with smaller inputs.
Divide and Conquer • Divide the problem into subproblems. • Conquer the subproblems by solving them recursively. • Combine the solutions to subproblems into the solution for original problem.
Tree Structure problem subproblem subproblem subsubproblem subsubproblem subsubproblem subsubproblem
Procedure divide conquer combine
Heapsort 16 14 10 3 9 8 7 2 4 1
Quicksort divide conquer combine is simplified
Selection with O(n) Comparisons divide conquer conquer
Remark on Divide and Conquer Key Point:
Merge Sort Quick Sort Selection Analysis requires to solve a recurrence!
n/2 Step 1 n/2
Step 2 Step 3