280 likes | 295 Views
Learn how to apply Divide-and-Conquer method to solve complex problems by breaking them down into smaller tasks recursively and combining the solutions effectively. Explore practical examples like Merge Sort, Quick Sort, and Heapsort. Key Point: Understand Analysis and use of Master Theorem.
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 divide 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