Backtracking Visualizer

Step through subsets or permutations, inspect the recursive decision tree, and watch the current path get chosen, recorded, and undone.

Items
3
Calls
15
Results
0
Total
8

Input

Subset mode keeps the first 5 unique items.

Step controls

Step 1 of 38: Call i=0, path=[].

Current path

Empty path

Decision tree

Call i=0, path=[].

Stack Active Result
Backtracking decision treeDecision tree with 15 recursive calls.startdepth 0take Adepth 1take Bdepth 2take Cdepth 3skip Cdepth 3skip Bdepth 2take Cdepth 3skip Cdepth 3skip Adepth 1take Bdepth 2take Cdepth 3skip Cdepth 3skip Bdepth 2take Cdepth 3skip Cdepth 3

Call stack

start

Results

No completed results yet.

What is a Backtracking Visualizer?

A backtracking visualizer shows recursive choices as a decision tree. Each branch represents choosing, skipping, or trying a candidate, and each return step shows the algorithm undoing the last choice.

This tool includes subset generation and permutation generation. It is useful for learning recursion, DFS decision trees, call stacks, and search-space pruning.

For the full cluster of related tools, browse the Data Structure Visualizers hub.

How to use this backtracking visualizer

  • Paste short labels such as A B C.
  • Choose subsets or permutations.
  • Step through recursive calls and return steps.
  • Watch the current path, remaining choices, and result list.
  • Use the tree to see where the algorithm backtracks.

Backtracking and recursion

Backtracking is recursion plus undoing choices. It explores one candidate path, records a result or failure, then returns to the previous choice point and tries another option.

Compare this page with the Recursion Tree Visualizer, Stack and Queue Visualizer, and Knapsack DP Visualizer.

Frequently Asked Questions

Which backtracking examples are supported?
This visualizer supports subsets and permutations, two common patterns used to learn recursive search.
Why is the input size limited?
Backtracking grows exponentially, so the input is limited to keep the diagram readable and the browser responsive.
What does the current path mean?
The current path is the set of choices currently on the recursion stack.
Does the visualizer show completed results?
Yes. As the algorithm reaches a base case, completed subsets or permutations appear in the result panel.

Related tools