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, helping find all or the best solutions.
Click to reveal answer
beginner
Why can't greedy algorithms solve all problems?
Greedy algorithms make the best local choice at each step but may miss the best overall solution because they don't reconsider earlier choices.
Click to reveal answer
intermediate
Give an example 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 combinations to find the correct subset.
Click to reveal answer
intermediate
How does backtracking explore the solution space?
Backtracking explores by building solutions incrementally and abandoning paths that cannot lead to a valid solution, effectively pruning the search space.
Click to reveal answer
intermediate
What is a key sign that a problem might need backtracking instead of greedy?
If the problem requires checking many combinations or the best global solution depends on future choices, greedy likely fails and backtracking is needed.
Click to reveal answer
Which approach tries all possible solutions and backtracks when stuck?
✗ Incorrect
Backtracking explores all options and undoes choices when they don't work.
Why might a greedy algorithm fail to find the best solution?
✗ Incorrect
Greedy algorithms pick the best immediate option, which may not lead to the best overall solution.
Which problem is a classic example where greedy fails but backtracking works?
✗ Incorrect
Subset Sum requires checking combinations, which greedy can't handle correctly.
What does backtracking do when it finds a dead end?
✗ Incorrect
Backtracking undoes the last choice and tries alternatives.
Which is a sign that backtracking might be needed?
✗ Incorrect
Backtracking is useful when many combinations must be explored.
Explain why greedy algorithms can fail and how backtracking solves those cases.
Think about local vs global decisions and exploring all possibilities.
You got /4 concepts.
Describe a real-life example where backtracking is better than greedy.
Imagine picking items to fit a bag exactly.
You got /4 concepts.