Greedy
Make the choice that looks best right now and never look back, and learn how to tell when that is actually correct.
After this lesson you will be able to
- Explain what a greedy algorithm is, and why it is fast but only sometimes correct.
- State the two properties that make greedy valid: the greedy-choice property and optimal substructure.
- Use an exchange argument to convince yourself a greedy rule is right.
- Find counterexamples that break a plausible-looking greedy rule.
- Solve interval scheduling, jump game, and assignment problems with sort-then-scan greedy solutions.
Before you start. Sorting Basics: most greedy solutions begin by sorting on the right key.