Talk:Greedy algorithm

From Wikipedia, the free encyclopedia

The page says that Kruskal's Algorithm is also a Greedy Algorithm. Tho actually this does not work locally, instead Kruskal always takes the smallest weight of all to add an edge to the set. It knows the whole set of edges and in opposite to Prim it takes the smallest weight - shouldnt we remove Kruskal from this page?

--- User:WhiteCrow 7/24/2005

I would find Kruskal's algorithm a more natural example of what I understand to be a greedy algorithm than Prim's. In fact, the phrasing seems somewhat unlucky: I'd describe a greedy algorithm as "an algorithm that repeatedly extends a partial solution in the way that increases the objective function most" (in the case of a maximization problem). In Prim's algorithm we maintain the invariant that the partial solution is a tree; in Kruskal's algorithm we're already happy with a forest. —The preceding unsigned comment was added by 131.155.68.93 (talk • contribs) 4 October 2005.
My PhD computer scientist wife read this over and says the article is basically OK. We looked at the algorithms book that I reference (a standard book on the subject) and it agrees with the article's content. About Kruskal's: the book also specifically characterizes Kruskal's as a greedy algorithm (p. 504). --Brianyoumans 09:42, 6 August 2006 (UTC)
Kruskal's algorithm is definitely greedy. When it adds an edge to the forest, it will never have to remove it from there. --ZeroOne (talk | @) 12:02, 30 November 2006 (UTC)

[edit] Example?

A little example (even pseudocode) would be convincing. Can someone add a typical greedy problem & solution to the article? —The preceding unsigned comment was added by 86.34.42.206 (talk • contribs) 19 March 2006.

See the image on the page for a simple example. Also see the linked articles Kruskal's algorithm and Dijkstra's algorithm. The first one has a complete example, the second one some pseudocode. --ZeroOne (talk | @) 17:42, 10 November 2006 (UTC)