trees section 6.5 6.5 trees 2 trees definition examples two examples

37
Trees Section 6.5

Post on 19-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Trees

Section 6.5

6.5 Trees 2

Trees

Definition

Examples

Two Examples

6.5 Trees 3

3 Topics

1. Minimal Cost Spanning

Trees

2. Counting Trees

3. Searching Trees

Animations

6.5 Trees 4

Minimal Cost Spanning TreeExample: A planned community

Build a road system to begin for a 1000-acre planned community. It will include a convenience store, golf course, tennis courts, and three condo units

The developer has two goals

1.

2.

6.5 Trees 5

27

3010

21

11 28

16

Golf

S

Condo 1

Condo 3

Tennis

14

18

19

16

30

3023

14

Condo 2

Units in

$1,000’s

6.5 Trees 6

Best of the 3 animations was $72,000. You can do better. Click when you find one

Got i

t

0%

2730

10

21

11 28

16

Golf

S

Condo 1

Condo 3

Tennis

14

18

19

16

30

3023

14

Condo 2

Units in

$1,000’s

1. Got it0 of 30

6.5 Trees 7

10

11

16

14

18

16

14

Yes

Yes

Yes

No, loop

Yes

No, loopYes

Stop

$ ,000

2730

10

21

11 28

16

Golf

SCondo 1

Condo 3

Tennis

14

18

19

1630

3023

14

Condo 2

Units in

$1,000’s

6.5 Trees 8

Summarize the Algorithm

1.

2.

3.

Resulting set of edges is called a

minimal cost spanning tree

Joseph Kruskal

6.5 Trees 9

Understanding the terms

“Minimal cost” = Obvious

“Spanning” = No isolated vertices

“Tree” = A graph with no loops

6.5 Trees 10

Continental Cable Vision will have to spend

$405,000 $456,000 $505,000 $528,000 None ofthe ab...

0% 0% 0%0%0%

1. $405,000

2. $456,000

3. $505,000

4. $528,000

5. None of the above

Avon

Simsbury

Suffield

Bloomfield

Vernon

SouthWindsor

92

82

94 80 77

10085

90

98

977

5

100

Granby

Units in $1,000’s

0 of 30

6.5 Trees 11

2. Counting

Two teams, A and B, play a “best-of 5” game series.

For example, here are some ways that A could win:

In how many different ways can A win the series?

6.5 Trees 12

And the answer is…?

6 8 10 12

0% 0%0%0%

1. 6

2. 8

3. 10

4. 12

0 of 30

6.5 Trees 13

A “Tree” Solution

6.5 Trees 14

“Red Sox vs. Yanks”

The Red Sox play the Yanks in an unusual 4-game series. If the visiting team (in this case the beloved Red Sox) wins two games, they win the series. The home team must win three games to win the series

For example:

In how many different ways can the series be played?

6.5 Trees 15

And the answer is…?

1. 4 ways

2. 6 ways

3. 8 ways

4. 10 ways

6.5 Trees 16

6.5 Trees 17

A red chip, a white chip, and a blue chip are placed in a container. A person blindly picks one chip, notes its color, and then replaces it in the container. The person then chooses a second chip from the container and notes its color.

Use a tree to determine the number of ways in which exactly one of the two chips drawn is the blue chip1. 2

2. 3

3. 4

4. 5

6.5 Trees 18

3. Searching

You secretly choose an integer from 1-100. I claim that I can find your number after I ask you X “yes/no” questions. What is X?

1. 7-10

2. 11-15

3. 16-20

4. More than 20

6.5 Trees 19

Range # Questions

1 - 1,000,000

1 - 100,000

1 - 10,000

1 - 1,000

1 - 100

End of 6.5

6.5 Trees 21

27

30

10

21

11 28

16

14

18

16

30

3023

19

14

Units are in

$1,000’s

$0$30,000$57,000$87,000$115,000$131,000

6.5 Trees 22

27

30

10

21

11 28

16

14

18

16

30

3023

19

14

Units are in

$1,000’s$0$30,000$53,000$67,000$94,000$122,000

6.5 Trees 23

27

30

10

21

11 28

16

14

18

16

30

3023

19

14

Units are in

$1,000’s$0$11,000$21,000$35,000$54,000$72,000

6.5 Trees 24

Family Trees

6.5 Trees 25

Zork

6.5 Trees 26

Minimal Cost Spanning Trees

Joseph B. Kruskal 1928 -

Meta - Material

6.5 Trees 280 / 30

100%

1

A tree has ten vertices of degree 2, ten vertices of degree 3, ten vertices of degree 4, one vertex of degree 5, and its remaining vertices have degree 1. How many vertices are in the graph?

1. Matt????

6.5 Trees 29

Cheapest Link

• Like NN start with two closest vertices, but keep on selecting pairs of vertices with the shortest distance between them. Not just the ones adjacent to the already selected pairs.

• Restrictions: don’t complete a circuit until all vertices are included

• A link may not be added if it results in more than two edges coming from the same vertex

6.5 Trees 30

Nearest Insertion

• Start once again with two closest vertices

• Then make a circuit using those two and a third vertex, namely the one that is nearer to either one of the original two vertices

• Now include the unused vertex closest to any of the three.

6.5 Trees 31

Bonus questions

• Jack and Jill were at a party with three other married couples. As people were introduced a good deal of handshaking took place.

• No one shook hands with his or her spouse• No none shook hands with herself or himself• No one shook hands with anyone more than once.

• When leaving the party, Jill asked the other seven people how many hands they had shaken aand received 7 different answers.

• How many hands did Jill shake at the party?• How many handshakes for Jack?

6.5 Trees 32

Ex. 3 Oil Pipeline

A pipeline is to be constructed to take oil across the northern part of Canada

Find the minimum cost to ship the oil between connecting points

6.5 Trees 33

A

B C

G

40

35

35

25

10

10

6020

60

20

5060

2050

60

15

25 3055

E

D

F50

30

Units in $10,000’s

6.5 Trees 340 / 30

0% 0% 0% 0% 0%

1 2 3 4 5

And, the answer is …..(Choose the closest answer)

1. $49,000

2. $55,000

3. $59,000

4. $69,000

5. $73,000

6.5 Trees 350 / 30

0% 0% 0% 0%

1 2 3 4

Test question?

If there are N locations (vertices), how many edges are there?

1. N

2. N + 1

3. N – 1

4. 5

6.5 Trees 36

Cable Service

Continental Cable Vision wishes to bring their services to 7 towns in CT. Every pair of towns must be connected by the service. Construct a minimal cost-spanning tree to solve the problem

Avon

Simsbury

Suffield

Bloomfield

Vernon

SouthWindsor

92

82

94 80 77

10085

90

98

977

5

100

Granby

Units in $1,000’s

6.5 Trees 37