Exam Format & Expectations
Greedy Choice questions typically ask you to:
- State the greedy algorithm - What choice does it make at each step?
- Prove correctness - Show the greedy choice is always safe
- State and prove the lemma - Formalize the greedy choice property
Key: The proof structure is usually: "Consider any optimal solution. We can modify it to include the greedy choice without losing optimality."
Past Exam Example: Interval Scheduling (2024)
Problem:
Given n intervals I = { I1, ..., In } where each interval Ii has:
- Start time s(Ii)
- Finish time f(Ii)
Two intervals Ii and Ij are compatible if they don't overlap. Goal: Find a maximum-size subset of mutually compatible intervals.
Question 2a: State the greedy algorithm
Greedy choice: Always select the interval with the earliest finish time that doesn't conflict with already selected intervals.
Question 2b: State and prove the Greedy Choice Lemma
Lemma: Let I be a set of intervals. Let Ik be the interval in I with the earliest finish time. Then there exists an optimal solution that contains Ik.
Proof:
- Let OPT be any optimal solution.
- If Ik ∈ OPT, we're done.
- Otherwise, let Ij be the interval in OPT with the earliest finish time.
- By definition of Ik: f(Ik) ≤ f(Ij)
- Consider OPT' = (OPT \ { Ij }) ∪ { Ik }
- Claim: OPT' is a valid solution.
- • Ik doesn't conflict with any interval in OPT \ { Ij }
- • Because f(Ik) ≤ f(Ij), and Ij didn't conflict with them
- |OPT'| = |OPT| → OPT' is also optimal
- OPT' contains Ik. QED.
Example: Fractional Knapsack (2023)
Problem:
Given n items where item i has weight wi and value vi. We have a knapsack of capacity W. We can take fractions of items. Goal: Maximize total value while respecting weight constraint.
Greedy Strategy
Sort items by value-to-weight ratio: vi/wi in decreasing order. Take items in this order, taking as much as possible of each item.
If an optimal solution takes fraction x < 1 of the highest-ratio item, we can improve it by taking more of this item and less of lower-ratio items.
This exchange argument shows the greedy choice is safe.
Common Proof Techniques
Exchange Argument
- 1. Take any optimal solution OPT
- 2. If it contains greedy choice, done
- 3. Otherwise, exchange to include greedy choice
- 4. Show the exchange doesn't decrease quality
- 5. Conclude greedy choice is safe
Staying Ahead
- 1. Show greedy is "ahead" at each step
- 2. Define what "ahead" means precisely
- 3. Prove by induction on steps
- 4. Conclude greedy is optimal at end
Exam Tip: Structure is Key
Always use numbered steps in your proof. State the lemma formally before proving it. The structure often matters as much as the content for grading.
How to Excel at Greedy Choice Problems
1. Identify the Greedy Choice
Look for extremal properties:
- Earliest/latest finish time
- Highest/lowest ratio or density
- Shortest/longest duration
- Leftmost/rightmost position
2. State the Lemma Precisely
"∃ an optimal solution that contains the greedy choice" is different from "all optimal solutions contain the greedy choice"
3. Exchange Carefully
When exchanging elements, verify that:
- The new solution is feasible
- The objective value doesn't decrease
- No constraints are violated