Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 9 Binary Trees.

Similar presentations


Presentation on theme: "Chapter 9 Binary Trees."— Presentation transcript:

1 Chapter 9 Binary Trees

2 Chap.9 Contents 9.1 Definition of Binary Tree
9.2 Properties of Binary Trees 9.3 The Binary Tree Theorem 9.4 External Path Length 9.5 Traversals of a Binary Tree

3

4 9.1 Definition of Binary Tree
binary tree t 可為 empty tree 或 包含: 一個 root element, 與兩個不同的 binary trees, 分別叫 t 的 left sub-tree 及 right sub-tree

5

6

7

8

9

10

11 Binary trees (elements 大小無規定)

12 Binary search tree (elements 左小右大)
2

13 Tri-nary (3-nary) search tree
2 4 What about N-nary search tree(n-元搜尋樹)? It is called B tree.

14

15 This is NOT a binary search tree
5 Because 4 is NOT less than 3

16

17

18 9.2 Properties of Binary Trees

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35 level (x), the level of x, is the same as the depth (x). Is height (t) the same as depth(x)? ANS: No. See next page, height(50) is 3. depth(62) is 2.

36

37

38

39

40

41

42

43

44

45

46

47

48 這暗示我們: Complete binary tree 可用 array來實作. A B C D E R S F G L

49

50

51

52

53

54

55 9.3 The Binary Tree Theorem

56

57

58

59

60

61

62

63

64

65 9.4 External Path Length

66

67

68

69 9.5 Traversals of a Binary Tree

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84 ANS: inOrder FDGBLEARCS postOrder FGDLEBRSCA preOrder ABDFGELCRS breathFirst ABCDERSFGL


Download ppt "Chapter 9 Binary Trees."

Similar presentations


Ads by Google