English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

a classic combinatorial problem is to place N queens on an N*N chessboard so that no two"attack",that is so that no two of them are on the same row,column or diogonal.The case study gives a graphical user interface simulation for this N queens problem.It will read the value N first then display each and every solution for this N queens problem in N*N chessboard.

2006-10-26 22:44:42 · 3 answers · asked by rachel 1 in Computers & Internet Programming & Design

3 answers

I wont be able to show the coding to you. But I could give you the algorithms. All you have to do is use the brute force algorithms which checks for all probability. This algorithms are really useful IF the n-value is small.
For bigger n-value, you'll have to use Dynamic Programming a.k.a DP algorithms.

Here's the quick look:
First, put the queen in 1,1 then put "false" in 1,2 to 1,N and 2,1 until 2,N and 2,2 until N,N.
Then put the next queen in 1,2. Since it has been labeled "false", the queen cant be put here.
Then move to next block, 1,3. Since it has been labeled "false" too. It is impossible for the queen to be placed here.
Then move until 3,2 where there is no "false" label, put the queen there and start the "label" process again.
Loop this until all the board has been labeled "false".

Got it?

Have fun!

peace
vixklen

2006-10-26 23:29:19 · answer #1 · answered by vixklen 3 · 0 1

N queen problem is an NP hard problem, means there is no shortcut. You should consider all the solutions. The second method in above solution is the only solution.

2006-10-27 15:21:55 · answer #2 · answered by manoj Ransing 3 · 1 0

PLEASE XPLAIN ME THE QUESTION

2006-10-27 06:07:53 · answer #3 · answered by Anonymous · 0 1

fedest.com, questions and answers