Skip to content

This repository contains solutions to the N-Queens problem using backtracking algorithms. It demonstrates placing N queens on an N×N chessboard so no two queens threaten each other, showcasing efficient backtracking techniques for various values of N.

Notifications You must be signed in to change notification settings

andersonmaina/DSA-Backtracking-for-N-Queens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

This repository features a comprehensive implementation of backtracking algorithms to solve the N-Queens problem plus the visualization of the algorithm. The N-Queens problem involves placing N queens on an N×N chessboard such that no two queens can attack each other. This solution is designed to efficiently explore all possible configurations, demonstrating the power and elegance of backtracking in algorithm design. The code is well-documented and includes various examples for different values of N, making it a valuable resource for anyone studying algorithms, data structures, or preparing for technical interviews. Contributions and optimizations are welcome to enhance the repository further.

<------HOW TO RUN----->

Install python from officiall website.

Create new folder in the desktop.

Open cmd and cd into the folder then run "git clone https://github.com/andersonmaina/DSA-Backtracking-for-N-Queens.git"

Cd into the newly created folder.

Run the commands below.

python -u "path_to_your_folder\DSA-Backtracking-for-N-Queens\nqueens.py"

To see the visualization of the algorithm run the command below(You need to have tkinter python module installed, run 'python -m tkinter' to check if its present).

python -u "path_to_your_folder\DSA-Backtracking-for-N-Queens\visualizer.py"

About

This repository contains solutions to the N-Queens problem using backtracking algorithms. It demonstrates placing N queens on an N×N chessboard so no two queens threaten each other, showcasing efficient backtracking techniques for various values of N.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages