Recursion & DP hard time O(n!) space O(n)
Backtracking — N-Queens
Place one queen per row. For each square check whether an earlier queen already attacks it down a column or a diagonal. If a row runs out of safe squares, the previous choice was wrong — take that queen back and try the next square. That retreat is backtracking.
Place 5 queens so none share a column or diagonal — one queen per row.
1 / 18
A fixed scene — scrub through it, or open the code.
Practice
Machine twin: /dsa-viz-v2/n-queens.json — the full deterministic run as structured data.