Pular para o conteúdo principal
Interactive Algorithm Education

Visualize & Master Algorithms & Data Structures

Explore classic & modern sorting algorithms, efficient searching techniques, and interactive data structure visualizations — all with real-time step-by-step animation, comparisons, swaps, and Big-O metrics.

Backtracking Visualizer

N-Queens

Passo 0 / 0
Speed 100ms
Step Progress 0 / 0
Recursion Depth 0
Pruned Branches 0
Status Ready
Empty
Placing / Active
Conflict / Pruned
Solution
Placed
Step Explanation

Select an algorithm and press Play to watch the search tree explore and backtrack.

—
Pseudocode
 
Backtracking Algorithms

Backtracking Algorithm Catalog

2 algorithms in this category. Click any card for detailed analysis.

N-Queens

Unstable

N-Queens places n queens on an n×n board so that no two queens attack each other (no shared row, column, or diagonal). Backtracking places queens row by row and undoes placements that lead to dead ends.

Ideal Use: Use N-Queens to learn backtracking, constraint satisfaction, and the classic board-search pattern that generalizes to scheduling and puzzle solving.
Best
O(n!)
Worst
O(n!)
Space
O(n)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Sudoku Solver

Unstable

The Sudoku solver fills every empty cell with a digit 1-9 such that each row, column, and 3×3 box contains every digit exactly once. Backtracking fills cells in order and undoes choices that violate the constraints.

Ideal Use: Use the Sudoku solver to practice constraint-satisfaction backtracking — the same pattern powers cryptoarithmetic, regex backtracking, and constraint solvers.
Best
O(9^(n²))
Worst
O(9^(n²))
Space
O(n²)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization
Backtracking Complexity Matrix

Complexity & Performance Tradeoffs

Side-by-side comparison of Big-O time and space complexity characteristics across backtracking algorithms.

Algorithm Best Time Average Time Worst Time Space Complexity Stability
N-Queens O(n!) O(n!) O(n!) O(n) Unstable
Sudoku Solver O(9^(n²)) O(9^(n²)) O(9^(n²)) O(n²) Unstable