This puzzle is called the 8 queens puzzle We can solve this puzzle by

# This puzzle is called the 8 queens puzzle we can

• 38

This preview shows page 31 - 38 out of 38 pages.

This puzzle is called the 8 queens puzzle. We can solve this puzzle by considering partial candidates. The partial candidates are arrangements of k queens in the first k rows of the board, all in different rows and columns.
Problem solving by backtracking Any partial solution that contains two mutually attacking queens can be abandoned, since it cannot possibly be completed to a valid solution. Backtracking is a problem solving strategy that can be applied only for problems which admit the concept of a "partial candidate solution" and a relatively quick test of whether it can possibly be completed to a valid solution. Thus the 8 queens puzzle can be solved by backtracking. Backtracking is often faster than a brute force strategy.
Problem solving by backtracking Any partial solution that contains two mutually attacking queens can be abandoned, since it cannot possibly be completed to a valid solution. Backtracking is a problem solving strategy that can be applied only for problems which admit the concept of a "partial candidate solution" and a relatively quick test of whether it can possibly be completed to a valid solution. Thus the 8 queens puzzle can be solved by backtracking. Backtracking is often faster than a brute force strategy.
Eight queens problem Algorithm: Start with one queen at the first column first row Continue with second queen from the second column first row Go up until find a permissible situation Continue with next queen
Eight queens problem Red cells show ruled out cells Placing First Queen Options for Second Queen So the next queen Q2 has to options: B3 or B4 Choose B3
Eight queens problem Red cells show ruled out cells Placed two Queens Options for third Queen No option for placing third queen Back track and choose B4 for second queen
Eight queens problem Red cells show ruled out cells Change two Queens Options for third Queen Third queen can be placed in C2 But Fourth queen cannot be placed else where Backtrack and change position of first queen to A2
Eight queens problem

#### You've reached the end of your free preview.

Want to read all 38 pages?

• Fall '16
• Jegan
• Eight queens puzzle

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern