In Chapter 2, Sorting Algorithms and Fundamental Data Structures, we introduced, among other sorting algorithms, merge and quick sort. A peculiarity of both algorithms is that they divide the problem into subproblems that are smaller instances of the same, solve each one of the subproblems recursively, and then combine the solutions to the subproblems into the solution for the original problem. This strategy forms the basis of the divide and conquer paradigm.
Getting Started with Divide and Conquer Algorithms
The Divide and Conquer Approach
In a divide and conquer approach, we solve a problem recursively, applying the following three steps at each level of recursion:
- Divide the problem into more than one subproblems...