Dynamic programming versus divide-and-conquer
In Chapters 4 and 5, we explored recursive algorithms and the methods to analyze their complexities. We also explored divide-and-conquer strategies. The fundamental idea behind a divide-and-conquer approach is to break down a problem into smaller subproblems, solve these subproblems optimally, and then combine their solutions to form the final solution. This process is typically carried out recursively, meaning that the problem is continuously divided into subproblems until we reach a point where the subproblem is so small that it can be solved intuitively or straightforwardly. This smallest, simplest problem is referred to as the base case.
Dynamic programming follows a similar strategy to divide-and-conquer. It breaks down a problem into subproblems with the explicit assumption that the optimal solution to any subproblem will contribute to the final optimal solution. This characteristic is known as the optimal substructure. While this...