Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

NQUEEN problem

$
0
0

hii guys,

i am trying to to do N-queen problem in which i have a function Place(k,i) which returns true if a queen can b placed at the K'th row and i'th column but am facing problem in understanding the following algorithm

Place(k,i)
{
for j=1 to k-1 do

     if((x[j]=i) or (abs(x[j]-i)=abs(j-k))

           then return false;


return true;

}

here x is a global array whose k-1 values are set

especially i fail to visualise the same diagonal and same column checking in the if block... :(


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>