The N queens problem asks: how many ways can N non-attacking queens be placed on an N×N chessboard? It is a fundamental benchmark problem in combinatorial optimization and artificial intelligence. Different algorithms tackle it with very different trade-offs between completeness, optimality, and speed.
Key dimensions to compare algorithms:
- Complete: Does it guarantee finding all solutions?
- Optimal: Does it find a solution (or best solution) in minimum time?
- Scalability: How does runtime grow with n?
- Implementation complexity: How hard is it to implement correctly?
For most use cases — finding all solutions, education, or interview prep — backtracking is the right choice. For finding a single solution quickly in large n, min-conflicts heuristic is often fastest. For exploring the problem from an AI perspective, see the 8 Queens in AI guide.