In actual life, algorithms we encounter fall into four categories:
I. Determination
Ii. Optimization Problems
Iii. Constructor
4. computing problems
The algorithm to be summarized today focuses on solving the optimization problem.
The following table summarizes the three algorithms:
|
Standard governance |
Dynamic Planning |
Greedy Algorithm |
Applicable type |
General problems |
Optimization Problems |
Optimization Problems |
Subproblem Structure |
Different sub-questions |
Many Sub-problems are repeated (not independent) |
Only one subproblem exists. |
Optimal sub-structure |
No |
Must meet |
Must meet |
Number of subproblems |
Resolve all sub-Problems |
Resolve all sub-Problems |
Only one sub-problem can be solved. |
Sub-problems are in the optimal solution |
All |
Part |
Part |
Selection and solving order |
Select first and then solve the sub-Problem |
Resolve the sub-problem first and then select |
Select first and then solve the sub-Problem |
Governance algorithm features:
1) if the scale is small, it is easy to solve. // General problems can be met
2) major problems can be divided into several small-scale problems. // Prerequisite
3) The subproblem can be combined into the solution of the subproblem. // Key
4) Each subproblem is independent of each other, and the subproblem does not contain any public subproblem. // High Efficiency
[1] dynamic planning:
Dependency: Depends on the optimal choices to be made
Essence: Divide governance and solve redundancy.
Bottom-up (each step gets a smaller problem according to the strategy. Finally, the minimum scale problem is solved. Obtain the optimal solution of the entire problem)
Feature: dynamic planning of any stage I + 1 depends only on the choice made by stage I. It has nothing to do with the selection before I. However, dynamic planning not only obtains the optimal value of the current state, but also obtains the optimal value of the intermediate state.
Disadvantage: large space requirements.
[2] greedy algorithm:
Dependency: depends on all the selected items.
Top-down (that is, each step obtains the current optimal solution according to the policy. Transfer to the next step to ensure that the current best step is selected. Final result)
[3] grouping algorithm:
Essence: recursive Solution
Disadvantage: If the subproblem is not independent, you need to repeat the public subproblem.