Recall & Review
beginner
What is the main idea behind backtracking?
Backtracking tries all possible options step-by-step and goes back (undoes) when a choice leads to a dead end, ensuring all solutions are explored.
Click to reveal answer
beginner
Why can't greedy algorithms solve all problems?
Greedy algorithms make the best choice at each step without looking ahead, which can miss the overall best solution in problems needing global decisions.
Click to reveal answer
intermediate
Give an example of a problem where greedy fails but backtracking works.
The "Subset Sum" problem: greedy might pick large numbers first and miss a valid subset, but backtracking tries all subsets to find the correct answer.
Click to reveal answer
intermediate
How does backtracking ensure correctness?
By exploring all possible choices and undoing wrong paths, backtracking guarantees finding all valid solutions or the best one if it exists.
Click to reveal answer
beginner
What is a key drawback of backtracking compared to greedy?
Backtracking can be slow because it tries many possibilities, while greedy is faster but may not always find the best solution.
Click to reveal answer
Which approach tries all possible options and backtracks on failure?
✗ Incorrect
Backtracking explores all options and undoes choices when they lead to dead ends.
Why might a greedy algorithm fail to find the best solution?
✗ Incorrect
Greedy algorithms make decisions based only on the current step without considering future consequences.
Which problem is a classic example where greedy fails but backtracking succeeds?
✗ Incorrect
Subset Sum requires checking combinations, which greedy cannot do correctly.
What is a main disadvantage of backtracking?
✗ Incorrect
Backtracking can be slow because it explores many possible paths.
Which algorithm type is best when you need the absolute best solution and can afford more time?
✗ Incorrect
Backtracking tries all options to find the best solution, though it may be slower.
Explain why greedy algorithms cannot solve all problems and how backtracking helps.
Think about choosing step-by-step vs exploring all paths.
You got /4 concepts.
Describe a scenario or problem where backtracking is necessary instead of greedy.
Consider problems where partial choices affect future options.
You got /4 concepts.