This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: SHEN’S CLASS NOTES 1 Chapter 16 Greedy Algorithms Like the dynamic programming, greedy algorithms are used to solve optimization problems also. Examples of optimization problems: (1) Find the largest number among n numbers. (2) Find the minimum spanning tree (MST) for a given graph. (3) Find the shortest path from vertex a to vertex z in a graph. A greedy algorithm works in stages also: (1) Initially, the greedy algorithm provides a simple partial solution (or a feasible solution) to the problem. For example, it can start with a single vertex for the MST problem. (2) At each stage, the greedy algorithm grows the current feasible or partial solution from previous stage to a larger, better, or more complete solution. After a number of stages, the algorithm stops when: (1) An optimal solution is obtained in O( f ( n )) time. In this case, we say that the algorithm solves the problem in O( f ( n )) time. (2) A good but sub-optimal solution is obtained. In this case, we say that this is an approximation algorithm. SHEN’S CLASS NOTES 2 Note that the greedy algorithms are different from dynamic programming in that the greedy algorithms usually grow only one unique partial solution at each stage. The dynamic programming develops a set of solutions at each stage and dynamically determines which solutions in previous stages should be used. Moreover, the dynamic programming must solve all smaller problems optimally. However, the dynamic programming and greedy algorithms do share a common idea that is to solve a large problem by solving smaller problems. This idea is also shared by smaller problems....
View Full Document