Algorithm For Professional Programmer

Tuesday, June 20, 2017

Algorithm NQueen(k,n)

// Using backtracking, this procedure prints all
//possible placements of n queens on an nXn
//chessboard so that they are nontracking.
{
for(i=1;i<=n;i++)
{
if(Place(k,i))then
{
x[k] = i;
if(k=n)then write(x[1:n]);
else NQueens(k+1, n);
}
}
}


Posted by Unknown at 9:16 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ▼  2017 (21)
    • ▼  June (21)
      • What is the Idea of Developing a DP Algorithm?
      • What is 0-1 Knapsack Problem?
      • What is the 8-Queens Problem
      • Algorithm NQueen(k,n)
      • What is Implicit Constraints?
      • What is Explicit Constraints?
      • What is the Formulation of the backtracking?
      • Two Different ways of tree generation
      • Merge Sort Algorithm
      • Finding the maximum and minimum number
      • Algorithm BinSearch(a,n,x)
      • Algorithm for recursive binary search
      • What is Branch and Bound?
      • What is Backtracking?
      • What is Bounding Function?
      • What is E-node?
      • What is A Dead Node?
      • What is Live Node?
      • Difference between backtracking & Branch and Bound
      • SumOfSub(s,k,r)
      • Sum of Subsets
  • ►  2016 (2)
    • ►  March (2)
Awesome Inc. theme. Powered by Blogger.