MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

11
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29

Transcript of MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Page 1: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

MATH 310, FALL 2003(Combinatorial Problem Solving)

Lecture 13, Monday, September 29

Page 2: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Example 3: Pitcher Pouring Puzzle We are given three pitchers of

water, of sizes 10 quarts, 7 quarts and 4 quarts.

Initially, the 10-quart is full and the other two pitchers are empty.

Is there a way to pour among pitchers to obtain exactly 2 quarts in one of the pitchers?

Page 3: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

The State Space The state space contains the following:

S – set of states s0 – initial state F – final or goal states (could be only one) P - set of rules D – Admissibility function D:P S

{True,False} U – Rule application: U:P S S.

Page 4: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Example 3: Pitcher Pouring Puzzle – Exercise 16(a)

We are given three pitchers of water, of sizes 8 quarts, 5 quarts and 3 quarts.

Initially, the 8-quart is full and the other two pitchers are empty.

Is there a way to pour among pitchers to obtain exactly 4 quarts in one of the pitchers?

Page 5: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Example 3: Pitcher Pouring Puzzle – Exercise 16(a)

We are given three pitchers of water, of sizes 8 quarts, 5 quarts and 3 quarts.

Initially, the 8-quart is full and the other two pitchers are empty.

Is there a way to pour among pitchers to obtain exactly 4 quarts in one of the pitchers?

Page 6: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

State Space Here is a part of the

state space for Exercise 16(a).

What is the initial state? What are the final

states? What are the rules? Are there any states

missing? Are there any edges

missing? Find DFS and BFS trees.

800

503 350

530

053

323

233

251

701 710 413

440

620602152

143

Page 7: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Example 4: Jealous Wives Puzzle. Three jealous wives

and three husbands come to a river.

The boat is for two people.

Find a sequence of boat trips that will get 6 people across the river without ever letting any husband to be without his wife in the presence of another wife.

A,a,B,b,C,c

Page 8: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Example 4: Jealous Wives Puzzle. Three jealous wives

and three husbands come to a river.

The boat is for two people.

Find a sequence of boat trips that will get 6 people across the river without ever letting any husband to be without his wife in the presence of another wife.

A,a,B,b,C,c

Page 9: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

A Center of a Tree T Let T be an arbitrary

tree and let r be any of its vertices. Let Tr be the tree rooted at r. Vertex r is called a center if the correspondig rooted tree Tr has minimal height. Compare Exercise 18, p. 103.

7

5

4 81

6

23

root 1 2 3 4 5 6 7 8

height 3 4 3 4 4 3 4 2

Page 10: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

4.1. Shortest Paths Homework (MATH 310#5M):

• Read 4.2. • Do Exercises 4.1: 1,2,4,6,8,10,12• Volunteers:

• ____________• ____________• Problem: 1.

No Section of Chapter 4 will be on Test 1.No Section of Chapter 4 will be on Test 1.

Page 11: MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 13, Monday, September 29.

Dijkstra’s Algorithm At each step of

the algorithm the (green) edge e between a labeled vertex p and unlabeled vertex q is selected in such a way, that

• d(p) + k(e)

is minimal.

a

Labeled verticesb

Unlabeled vertices

p

q

a