Common Mistakes

Common errors to avoid

  • Assuming greedy without proof: Always verify greedy choice property.

Counterexamples prove greedy doesn't work.

  • Wrong greedy criterion: Sorting by wrong attribute or choosing wrong "best" element leads to suboptimal solutions.
  • Not handling ties correctly: When multiple choices are equally good, ensure your tiebreaker doesn't break correctness.
  • Forgetting edge cases: Empty input, single element, all same values often need special handling.