Workspace Backtracking
0d
Problem-solving patterns

Choose, Explore, Restore

Build one path at a time and undo its last choice before visiting a sibling.

Recognition signal

The answer space is a tree of partial assignments.

Method

Prune invalid prefixes and copy a valid leaf for the result.

Worked example

For subsets of [A, B], choosing A leads to leaves [A] and [A, B].

Common mistake

A mutable path stored by reference may be empty after the search returns.