Recall & Review
beginner Click to reveal answer
What is the main idea behind the greedy approach?
The greedy approach makes the best choice at each step, hoping to find the overall best solution without reconsidering previous choices.
beginner Click to reveal answer
What does Dynamic Programming (DP) do differently from greedy?
DP solves problems by breaking them into smaller overlapping subproblems, solving each once, and storing results to avoid repeated work.
intermediate Click to reveal answer
When should you consider using a greedy algorithm?
Use greedy when the problem has the 'greedy choice property' and 'optimal substructure', meaning local best choices lead to a global best solution.
intermediate Click to reveal answer
What is 'optimal substructure' in the context of DP and greedy?
Optimal substructure means the optimal solution to a problem contains optimal solutions to its subproblems.
intermediate Click to reveal answer
How can you tell if a problem requires DP instead of greedy?
If the problem has overlapping subproblems and no greedy choice property, meaning local best choices don't guarantee global best, use DP.
Which property must a problem have for a greedy algorithm to work correctly?
✗ Incorrect
The greedy choice property ensures that making the best local choice leads to the global optimum.
What does Dynamic Programming use to avoid repeated work?
✗ Incorrect
DP stores results of subproblems using memoization or tabulation to avoid recalculating them.
If a problem has overlapping subproblems but also a greedy choice property, which approach is better?
✗ Incorrect
If greedy choice property holds, greedy is simpler and efficient even if subproblems overlap.
Which of these problems is typically solved by Dynamic Programming?
✗ Incorrect
Coin change with unlimited coins has overlapping subproblems and no greedy choice property, so DP is used.
What is a sign that greedy might fail for a problem?
✗ Incorrect
If local best choices don't guarantee global best, greedy approach can fail.
Explain how to decide between using a greedy algorithm and dynamic programming for a problem.
Think about problem properties and how solutions build up.
You got /5 concepts.
Describe the key differences in approach between greedy algorithms and dynamic programming.
Focus on how each method builds the solution.
You got /5 concepts.
