1 / 10

A Las Vegas Algorithm for the 8 Queens problem

A Las Vegas Algorithm for the 8 Queens problem. Lecture 35 CS 312. The Final. http://faculty.cs.byu.edu/~jones/312/sample_final.pdf (or .doc) In the testing center Use their calculators. Multiple choice. Show work for partial credit Review on Wednesday. Objectives. Finish project 4

anniel
Download Presentation

A Las Vegas Algorithm for the 8 Queens problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Las Vegas Algorithm for the 8 Queens problem Lecture 35 CS 312

  2. The Final • http://faculty.cs.byu.edu/~jones/312/sample_final.pdf (or .doc) • In the testing center • Use their calculators. • Multiple choice. • Show work for partial credit • Review on Wednesday

  3. Objectives • Finish project 4 • Explain the difference between Monte Carlo and Las Vegas algorithms • Decide how many queens to place at random in 8 queens.

  4. QueensLV queensLV (n,stopLV) : bool = place stopLV of the queens at random so that no queens attack each other. use backtracking to place the remaining n-stopLV queens if successful, report a solution otherwise fail.

  5. QueensLV 1 Random 2 3 4 5 Backtrack 6 7 8 1 2 3 4 5 6 7 8

  6. How many nodes explored? • suppose s(n) nodes to succeed • and f(n) nodes to fail • with probability p(n) of succeeding

  7. How many nodes explored? • suppose s(n) nodes to succeed • and f(n) nodes to fail • with probability p(n) of succeeding • t(x) = p(x)s(x) + (1-p(x))(f(x) + t(x)), or

  8. Nodes Explored

  9. How much time? • Authors report that for 8-queens, backtracking is still faster. • takes a long time to gen. a random number • For 39 queens, queensLV is faster. • 41 hours using backtracking • 8.5 ms using queensLV

  10. Homework • None. Cancelled.

More Related