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

This puzzle is called the 8 queens puzzle we can

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.
Image of page 31
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.
Image of page 32
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.
Image of page 33
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
Image of page 34
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
Image of page 35
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
Image of page 36
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
Image of page 37
Eight queens problem
Image of page 38

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

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors