P. 1


|Views: 9,685|Likes:
Published by Meena Bhagavathula

More info:

Published by: Meena Bhagavathula on Mar 12, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Dynamic programming was first popularized in the book by Bellman (1957).
Other books in this area include Bellman and Dreyfus (1962), Dreyfus
(1977) and Nemhauser (1966). Two general survey papers by Brown (1979)
and Held and Karp (1967) are highly recommended. The all-pairs short-
est paths algorithm is due to Floyd (1962). Matrix chain multiplication is
described in Godbole (1973). An O(nlogn) algorithm to solve this prob-
lem can be found in Hu and Shing (1980, 1982, 1984). The one and two
dimensional knapsack problems have been studied extensively; see for ex-
ample Gilmore (1977), Gilmore and Gomory (1966) and Hu (1969). Held
and Karp (1962) gave an O(n2


) dynamic programming algorithm for the
traveling salesman problem. This algorithm also appears in Horowitz and
Sahni (1978).


First-Cut Techniques




When a solution to a problem is sought, perhaps the first strategy that
comes to one’s mind is the greedy method. If the problem involves graphs,
then one might consider traversing the graph, visiting its vertices and per-
forming some actions depending on a decision made at that point. The
technique used to solve that problem is usually specific to the problem itself.
A common characteristic of both greedy algorithms and graph traversal is
that they are fast, as they involve making local decisions.
A graph traversal algorithm might be viewed as a greedy algorithm and
vice-versa. In graph traversal techniques, the choice of the next vertex to
be examined is restricted to the set of neighbors of the current node. This
is in contrast to examining a bigger neighborhood, clearly a simple greedy
strategy. On the other hand, a greedy algorithm can also be viewed as a
graph traversal of a particular graph. For any greedy algorithm, there is
an implicit directed acyclic graph (dag) each of whose nodes stands for a
state in that greedy computation. An intermediate state represents some
decisions that were already taken in a greedy fashion, while others remain
to be determined. In that dag, an edge from vertex u to vertex v exists only
if in the greedy method the algorithm’s state represented by v is arrived at
from that represented by vertex u as a consequence of one decision by the
greedy algorithm.

Although these techniques tend to be applied as initial solutions, they
rarely remain as the providers of optimal solutions. Their contribution
consequently is one of providing an initial solution that sets the stage for
careful examination of the specific properties of the problem.
In Chapter 8, we study in detail some algorithms that give optimal solu-
tions to well-known problems in computer science and engineering. The two
famous problems of the single-source shortest path, and finding a minimum
cost spanning tree in an undirected graph are representative of those prob-
lems for which the greedy strategy results in an optimal solution. Other
problems, like Huffman code, will also be covered in this chapter.
Chapter 9 is devoted to graph traversals (depth-first search and breadth-
first search) that are useful in solving many problems, especially graph and
geometric problems.


Chapter 8

The Greedy Approach

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->