Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.21/5 (5 votes)
See more:
I want a solution for 8 queen problem with recursive function.
whould you pleaze help me?
thanks.
Posted
Updated 19-Dec-11 1:02am
v3
Comments
Mohibur Rashid 19-Dec-11 6:27am    
Did you read the algorithm yet?

Didn't you understand?
Chuck O'Toole 19-Dec-11 11:26am    
Wow, deja vu. This was my final homework assignment for Computer Science 1 in 1966. They're still using it! Of course, that was before the internet so I had to do it myself.
Mohibur Rashid 19-Dec-11 20:47pm    
Hey chuck, I did that too but not as assignment, I did that for fun. And I solved three time, first two solution was before learning backtracking, first solution used to take like 10 minutes to find all the solution :)))

If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"
 
Share this answer
 
 
Share this answer
 
Comments
Amir Mahfoozi 19-Dec-11 7:02am    
+5
LaxmikantYadav 23-Dec-11 8:45am    
Thanks :)
If I were you I tried to solve it myself because it helps you improve your programming skills.

Here is a sample pseudo code for implementing it :

solve(int rowNo, int totalRows)
{
  if (rowNo>totalRows)
     dump the board configuration

  for all the cells in current row 
    if it is possible to place a queen in this cell
       {
          place a queen in this cell
          solve(rowNo+1, totalRows)
       }

}


Then call it with this values
solve(1, 8);


you can dump the board every time you reach to a leaf state in states tree, or you can increase a global counter.

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900