Table of Contents
Fetching ...

Solving N-Queen Problem using Las Vegas Algorithm with State Pruning

Susmita Sharma, Aayush Shrestha, Sitasma Thapa, Prashant Timalsina, Prakash Poudyal

TL;DR

Problem: efficiently finding a valid $N$-Queens arrangement, especially for large $N$, where complete backtracking is exponential. Approach: combine a Las Vegas randomized search with dynamic state pruning to eliminate invalid placements during random assignment. Contributions: a two-component algorithm (Invalid Points and Las Vegas core), formal loop-invariant analysis, and empirical results showing faster solution generation with acceptable variability compared to backtracking. Significance: offers a scalable, single-solution CSP solver suited for resource-constrained environments, with avenues for extending to other problems and hybrid strategies.

Abstract

The N-Queens problem, placing all N queens in a N x N chessboard where none attack the other, is a classic problem for constraint satisfaction algorithms. While complete methods like backtracking guarantee a solution, their exponential time complexity makes them impractical for large-scale instances thus, stochastic approaches, such as Las Vegas algorithm, are preferred. While it offers faster approximate solutions, it suffers from significant performance variance due to random placement of queens on the board. This research introduces a hybrid algorithm built on top of the standard Las Vegas framework through iterative pruning, dynamically eliminating invalid placements during the random assignment phase, thus this method effectively reduces the search space. The analysis results that traditional backtracking scales poorly with increasing N. In contrast, the proposed technique consistently generates valid solutions more rapidly, establishing it as a superior alternative to use where a single, timely solution is preferred over completeness. Although large N causes some performance variability, the algorithm demonstrates a highly effective trade-off between computational cost and solution fidelity, making it particularly suited for resource-constrained computing environments.

Solving N-Queen Problem using Las Vegas Algorithm with State Pruning

TL;DR

Problem: efficiently finding a valid -Queens arrangement, especially for large , where complete backtracking is exponential. Approach: combine a Las Vegas randomized search with dynamic state pruning to eliminate invalid placements during random assignment. Contributions: a two-component algorithm (Invalid Points and Las Vegas core), formal loop-invariant analysis, and empirical results showing faster solution generation with acceptable variability compared to backtracking. Significance: offers a scalable, single-solution CSP solver suited for resource-constrained environments, with avenues for extending to other problems and hybrid strategies.

Abstract

The N-Queens problem, placing all N queens in a N x N chessboard where none attack the other, is a classic problem for constraint satisfaction algorithms. While complete methods like backtracking guarantee a solution, their exponential time complexity makes them impractical for large-scale instances thus, stochastic approaches, such as Las Vegas algorithm, are preferred. While it offers faster approximate solutions, it suffers from significant performance variance due to random placement of queens on the board. This research introduces a hybrid algorithm built on top of the standard Las Vegas framework through iterative pruning, dynamically eliminating invalid placements during the random assignment phase, thus this method effectively reduces the search space. The analysis results that traditional backtracking scales poorly with increasing N. In contrast, the proposed technique consistently generates valid solutions more rapidly, establishing it as a superior alternative to use where a single, timely solution is preferred over completeness. Although large N causes some performance variability, the algorithm demonstrates a highly effective trade-off between computational cost and solution fidelity, making it particularly suited for resource-constrained computing environments.

Paper Structure

This paper contains 12 sections, 6 figures, 5 tables, 2 algorithms.

Figures (6)

  • Figure 1: Las Vegas Algorithm Attempt Distributions for n = 8, 22, 36
  • Figure 2: Central Tendencies for Las Vegas
  • Figure 3: Comparision With Backtracking
  • Figure 4: Las Vegas Algorithm Attempt Distributions for Various Values of n
  • Figure 5: Nqueen Solution visualized
  • ...and 1 more figures