Practice Discrete Math

Algorithms / Backtracking State Space

Least You Need to Know: Backtracking as Search Over Partial Choices

Backtracking explores a **state space of partial decisions**. The key idea is to build a candidate step by step, detect impossible or completed states early, and undo choices cleanly when a branch cannot lead to a valid answer.

The least you need to know

Key notation

state current partial assignment being explored
choose / explore / unchoose make one decision, recurse, then undo it
solution a complete state that satisfies all constraints

Tiny worked example

  • To generate valid choices, start from an empty partial state.
  • Pick one candidate decision and add it.
  • Recurse on the smaller remaining problem.
  • When the recursive call returns, undo that decision so the next branch starts from a clean state.

Common mistakes

How to recognize this kind of problem

Start practice