Greedy algorithm
Also called: Greedy
An algorithm that makes the choice that looks best right now at every step, and never reconsiders it.
Definition
Greedy algorithms are simple and fast, often a sort plus one pass, but they are only correct when a locally best choice can never ruin the overall result. That has to be argued, usually with an exchange argument: any optimal solution can be changed step by step into the greedy one without getting worse. When the argument fails, dynamic programming is the usual alternative.
In practice
To fit the most meetings into one room, always pick the meeting that ends earliest among those that still fit.
Learn it in context
Lessons that use this term.