N-Queens
Place one queen per row. A column or diagonal conflict forces backtracking.
Backtracking: 4 queens, with backtracking
Row 1, square (1, 0): the queen in row 0 is in the same column. Try the next square.
Cost
- Best
- O(n!)
- Average
- O(n!)
- Worst
- O(n!)
- Space
- O(n)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Backtracking covers these too, in the same run.