Table of Contents

Chapter 4

Greedy Algorithms

“Greed… is good. Greed is right. Greed works” - Wall Street.

Greed algorithm definition:

Two methods of proof

All this leads up to minimum spanning tree!

4.1 Interval Scheduling: The Greedy Algorithm Stays Ahead

Greedy rule that works

Show that this algorithm is optimal

Scheduling all Intervals

4.2 Scheduling to Minimize Lateness: An exchange Argument

4.3 Optimal Catching: A more Complex Exchange Argument

4.4 Shortest Paths in a Graph

Problem = how to find the shortest paths either from one point to another or to all the points.

4.5 The Minimum Spanning Tree Problem

4.6 implementing Kruskal's algorithm: the union-find data structure

4.7 Clustering

The problem

clustering of maximum spacing

Designing the algorithm:

Analyzing the algorithm

4.8 HUffman codes and data compression

encoding symbols using bits

Variable-length encoding schemes

prefix code

designing the algorithm

Analyzing Huffman's algoirthm

extensions