Master Software Engineering Journey!
N Queens Backtracking
In this problem or puzzle, N queens will be given and the challenge is to place all of them in N x N chessboard so that no two queens are in attacking position. What that means is we need to find the configuration of N queens where any of the two queens do not share a row, column and diagonal paths.
One of the better and elegant solutions to this puzzle is ‘backtracking algorithm’. While we are going through the solution to the problem let us also explore the technique of backtracking.
Find all valid configuration of N Queens puzzle. To understand this better, let us look into an example – 4 queen’s problem. I am taking the 4 queens problem as there are no solutions for 2 and 3 queen’s problem and 1 queen problem is trivial one. For this, we are given 4 x 4 chessboard and…
View original post 881 more words