Welcome to: - PowerPoint PPT Presentation

About This Presentation
Title:

Welcome to:

Description:

What two words add up to 'stuff'? How many different ways to ... Don't forget Sacagawea. 7/13/09. Explore Carolina 2004. 29. 4. Solving the 9 square problem. ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 32
Provided by: wei8
Learn more at: http://www.cs.unc.edu
Category:

less

Transcript and Presenter's Notes

Title: Welcome to:


1
Welcome to Chapel Hill UNC Computer Science
2
Steve Weiss Department of Computer
Science University of North Carolina at Chapel
Hill weiss_at_cs.unc.edu
3
Parallel computing
4
(No Transcript)
5
Brute force and backtracking(or how to open your
friends lockers)
6
The puzzle
7
Other puzzles
  • What two words add up to stuff?
  • How many different ways to make 1.00 in change?
  • Unscramble eeiccns

8

9
Brute force problem solving
Generate candidates
Filter
Solutions
Trash
10
Requirements
  • Candidate set must be finite.
  • Must be an Oh yeah! problem.

11
Example
Combination lock 606060 216,000 candidates
12
Example
13
Oh no!
14
Oh yeah!
15
Additional restrictions
  • Solution is a sequence s1, s2,,sn
  • Solution length, n, is known (or at least
    bounded) in advance.
  • Each si is drawn from a finite pool T.

16
Cavers right hand rule
17
Generating the candidates
Classic backtrack algorithm At decision point,
do something new (extend something that hasnt
been added to this sequence at this place
before.) Fail Backtrack
Undo most recent decision (retract).
Fail done
18
Problems
  • Too slow, even on very fast machines.
  • Case study 8-queens
  • Example 8-queens has more than
    281,474,976,711,000 candidates.

19
8-queens
  • How can you place 8 queens on a chessboard so
    that no queen threatens any of the others.
  • Queens can move left, right, up, down, and along
    both diagonals.

20
Problems
  • Too slow, even on very fast machines.
  • Case study 8-queens
  • Example 8-queens has more than
    281,474,976,711,000 candidates.

21
Faster!
  • Reduce size of candidate set.
  • Example 8-queens, one per row, has only
    16,777,216 candidates.

22
Richard Feynman
23
Faster still!
  • Prune reject nonviable candidates early, not
    just when sequence is complete.
  • Example 8-queens with pruning looks at about
    16,000 partial and complete candidates.

24
Still more puzzles
  • Map coloring Given a map with n regions, and a
    palate of c colors, how many ways can you color
    the map so that no regions that share a border
    are the same color?

25
  • Solution is a sequence on known length (n) where
    each element is one of the colors.

1
2
4
3
26
  • 2. Running a maze How can you get from start to
    finish legally in a maze?

20 x 20 grid
27
  • Solution is a sequence of unknown length, but
    bounded by 400, where each element is S,
    L, or R.

28
  • 3. Making change.
  • How many ways are there to make 1.00 with coins.
    Dont forget Sacagawea.

29
  • 4. Solving the 9 square problem.
  • Solution is sequence of length 9 where each
    element is a different puzzle piece and where the
    touching edges sum to zero.

30
Lets try the 4-square puzzle
  • Use pieces A, B, F, and G and try to arrange into
    a 2x2 square.

31
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com