Skip to content

Kaviya12223/N-Queen-Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

N-Queen-Visualizer

PROBLEM DESCRIPTION : The n-queens puzzle is the problem of placing n queens on an n_×_n chessboard such that no two queens attack each other. The goal is to find all possible ways to arrange the queens, ensuring that no two are in the same row, column, or diagonal.

Rules of NQueens : A queen can attack another queen if they are placed in the same row, column, or diagonal. The solution requires that no two queens are positioned in such a way that they can attack each other.

Backtracking Approach : The most common solution for the NQueens problem is through backtracking. It tries to place queens one by one, starting from the first column, and checks for safety at each step. If placing a queen in a certain row and column leads to no conflict, it moves on to place the next queen. If a conflict arises, it backtracks by removing the last queen placed and tries a different position.

Algorithm Steps : Start with an empty board. Place a queen in the first column of a row. Move to the next column and place another queen, ensuring it's safe. If no safe position is found in a column, backtrack to the previous column and reposition the queen. Continue this process until all queens are placed or all possible arrangements have been checked.

Time Complexity : The time complexity of the backtracking solution is O(N!). This is because for each queen placed, the algorithm checks all rows in the next column.

Challenges : As N increases, the number of possible board configurations grows exponentially, making it computationally expensive for larger values of N.

Conclusion : NQueens demonstrates the power of backtracking in solving complex combinatorial problems. The solution is elegant but computationally intensive, highlighting the trade-off between exhaustive search and efficiency.

About

N-Queen Visualizer Project in java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages