A greedy algorithm commits to a locally preferred next choice without revisiting earlier choices. Its rule needs a justification to guarantee a globally optimal result: the largest-individual-value rule in the 0-1 knapsack problem example fails, whereas Dijkstra's algorithm correctly settles the smallest tentative distance under its nonnegative-edge assumptions.

Articles by others on the same topic (NaN)

A greedy algorithm is a computational method that makes the most optimal choice at each step with the hope of finding the global optimum. The fundamental principle behind greedy algorithms is to build up a solution piece by piece, always choosing the next piece that offers the most immediate benefit (i.e., the most "greedy" choice), without considering the long-term consequences.