0
0
DSA Typescriptprogramming~5 mins

Why Backtracking and What Greedy Cannot Solve in DSA Typescript - Quick Recap

Choose your learning style9 modes available
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?
ABacktracking
BGreedy
CDivide and Conquer
DDynamic Programming
Why might a greedy algorithm fail to find the best solution?
AIt uses recursion.
BIt tries all combinations.
CIt only looks at local best choices, not the whole problem.
DIt sorts the input first.
Which problem is a classic example where greedy fails but backtracking works?
ABinary Search
BSubset Sum
CMerge Sort
DBreadth-First Search
What does backtracking do when it finds a dead end?
AIt goes back and tries a different path.
BIt stops immediately.
CIt picks the next best local choice.
DIt sorts the data.
Which is a sign that backtracking might be needed?
AThe problem is linear.
BThe problem is sorted.
CThe problem has only one solution.
DThe problem needs checking many combinations.
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.