29
Chapter 3 Trees and Forests 大大大大 大大大大大 大大大 2011.9

Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

Embed Size (px)

Citation preview

Page 1: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

Chapter 3 Trees and Forests

大葉大學 資訊工程系 黃鈴玲2011.9

Page 2: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

3.1 Trees and Some of Their Basic Properties 3.2 Characterizations of Trees 3.3 Inductive Proofs on Trees 3.5 Centers in Trees 3.6 Rooted Trees 3.7 Binary Trees 3.8 Levels in Rooted and Binary Trees

2

Page 3: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

3

Definition 3.1

Page 4: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

4

star

Ex 3.3

Page 5: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

5

Example 3.2字典找字的方式: a rooted tree

Page 6: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

6

Definition 3.3

Theorem 3.4

Ex 3.18

Page 7: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

7

Lemma 3.6

Page 8: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

8

Theorem 3.7

Proof

Page 9: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

9

Example 3.8

Proof

Regular binary tree: all vertices have degree 3 or less.

Let d3(n) denote the maximum number of vertices of degree 3that such a tree T on n vertices can have. Then

12

)(3

n

nd

(see Ex3.5)

Let x, y, and z be the number of vertices in T of degree 1, 2, 3.

Then x+y+z=n and x+2y+3z=2n2,

y+2z=n2 2z n2 z n/2 1

Page 10: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

10

Page 11: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

11

Definition 3.15

G: a graph. For u, v V(G), the distance between u and v,denoted (u,v), is the length of the shortest u, v-path in G.

Page 12: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

G:

A model of a street system:

Q: How to place the police station and fire station?

edge: streetvertex: intersection

Page 13: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

Minimize the response time between thefacility and the location of a possible emergency( 以出發後能最快到達事故地點為訴求 )(choose x to minimize max{(x,v) | v V(G) })

Page 14: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

14

Definition 3.18 ( 離心率及中心 )

Example 3.19 Tree 中 eccentricity 值最大的一定發生在 leaves

removing all leaves, 使 (u) 減少 1

Page 15: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

15

Theorem 3.20

Theorem 3.21

Page 16: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

16

Exercise Find the distance of u,v, and their eccentricities.

u

v

Page 17: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

17

Exercise

Exercise

Find all centers of the graph.

Page 18: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

18

Definition ( 直徑及半徑 )

The diameter of a graph G is

diam(G) = max{ (u, v) : u, v V(G) } = max{(u) : u V(G) }

The radius of a graph G is

rad(G) = min{(u) : u V(G) }

Exercise Find the diameters and radii of the graphs in Exercise 3.21 and 3.22.

Page 19: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

19

3.6 Rooted Trees3.6 Rooted TreesDefinition 3.22

Example 3.23

Page 20: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

20

Definition 3.24

Page 21: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

21

Example 3.25

Page 22: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

22

Definition 3.26

Example 3.27

Page 23: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

23

3.7 Binary Trees3.7 Binary TreesDefinition 3.28

Figure 3.15

Page 24: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

24

Definition 3.29

Ex 3.33 Draw the regular binary trees on nine vertices.

Page 25: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

25

Theorem 3.31

Pf.

若 tree 有 k 個 internal vertex ,則 每個 internal vertex 有 2 個 children , 故 tree 共有 2k 個點是 children ( 因每個 child 只有一個 parent ,所以只會被計算一次 ) root 沒有 parent ,還沒被計算到

∴tree 共有 2k +1 個點 共有 k +1 個 leaves

Page 26: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

26

3.8 Levels in Rooted and Binary 3.8 Levels in Rooted and Binary TreesTreesDefinition 3.37

Page 27: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

27

Observation 3.38

Pf.

(a) If ht(T)= k, then n 20+21+…+2k = 2k+1 1

∴ n+1 2k+1 lg(n+1) k+1 lg(n+1)1 ht(T) (b) Every vertex except the leaves has exactly two children, each level (except level 0) must contain at least two vertices.

n 2ht(T) 1 ht(T) (n1)/2

( 對照下一頁的圖 )

Page 28: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

28

Example 3.39

Page 29: Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲 2011.9

29

Definition 3.41

Observation

(level 0 ~ k1 都全滿 , level k 不要求 )