Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

Branching Choices

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Choose, explore, undo: Branching Choices.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Backtracking decision tree matches the clues
  2. 2Keep this true after every move: the current path contains exactly the choices for this branch
  3. 3Reach the result within O(2ⁿ)

Rules and pressure

  • Target cost: O(2ⁿ)
  • State rule: the current path contains exactly the choices for this branch
Lesson 1 of 3

Live algorithm trace

Backtracking decision tree

Complete execution
1 of 7
1
choice
2
3

Record the empty subset at the decision-tree root.

1record current path
2for each next choice
3choose and recurse
4undo the choice
path = []recorded = 1
Truth to preserve / Cost target
Truth to preserve

the current path contains exactly the choices for this branch

Cost target

O(2ⁿ)

Backtracking explores a decision tree. Add a choice, recurse into that branch, then remove the choice so the next branch starts from clean state.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead