Greedy Algorithms8 sections · 316 units
Open in Course

The Problem with Intuition

When feelings fail

Your intuition can mislead you. Consider making change for 3030 cents with coins of 2525, 1010, and 11 cent. Greedy (take largest first) gives: 2525 + 11 + 11 + 11 + 11 + 11 = 66 coins. But 1010 + 1010 + 1010 = 33 coins. Greedy gave the wrong answer!

Without a proof technique, you might submit a greedy solution that fails on hidden test cases. The techniques in this section will help you catch these errors before submission. You will learn when greedy works and when it does not.