ADA | Concept of Backtracking

Concept of Backtracking

Backtracking is a type of algorithm which is used to find all or some solutions to some computational problem.
Some general problems related to backtracking are
  • N Queen Problem
  • Rat & Maze Problem
  • The Knight's Tour Problem 
And many other problems

In this we will know about the N Queen problem.

N Queen problem

The N Queen problem is a problem of placing N numbers of queens on a N x N chess board in such a way that no two queens attack each other i.e. vertically, horizontally or diagonally.

Following is the solution of 4 Queen Problem.
4-queen-problem-backtracking


Problem Statement

In any puzzle/square chess board ,if one queen can attack another queen then how can we avoid the number of attack.
SolForEve-4queen-output

No comments:

Powered by Blogger.