The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by linacd_1973, 2021-08-05 21:34:41

CHAPTER 3 DBM20083 GRAPH AND TREE

CHAPTER 3 DBM20083 GRAPH AND TREE

Trees Binary Search Tree

 Build a binary search tree for the set of data below;
 Manggo Pineapple Banana Apple Strawberry Berry Durian

Manggo

Banana Pineapple

Apple Berry Strawberry

Durian

Azlina Binti Morshidi/JMSK/PKS

Trees

Tree Traversals
 In what order are the vertices of the tree in figure below processed
if pre-order traversal, in-order traversal and post-order traversal
are used?

20

7 25

3 15 30

10 19 27
12

Trees

Tree Traversals
 Pre-Order

1 20

7 25

2 8
9
3 30
22
3 15
7 10
4

5

10 19

27

6

12

20 7 3 15 10 19 12 25 22 30 27

Azlina Binti Morshidi/JMSK/PKS

Trees

Tree Traversals
 In-Order

20

7 7 25

1 8

6 22 30

32 15 9 10

3

10 4 5 19 27

12

3 7 10 15 12 19 20 22 25 27 30

Azlina Binti Morshidi/JMSK/PKS

Trees

Tree Traversals
 In-Order

20

7 7 25

1 8

6 22 30

32 15 9 10

3

10 4 5 19 27

12

3 7 10 15 12 19 20 22 25 27 30

Azlina Binti Morshidi/JMSK/PKS

Trees 20 10

Tree Traversals 5 25
 Post-Order 6
9
7 15
22 30
3 4
78
1

10 19 27

3
2

12

3 10 12 19 15 7 22 27 30 25 20

Azlina Binti Morshidi/JMSK/PKS

Trees

Full and Complete Binary Tree
 Here are two important types of binary trees.
 Full binary tree: a binary tree in which each node has exactly zero
or two children.
 Complete binary tree: A binary tree which is completely filled, with
the possible exception of the bottom level which is filled from left
to right.

Azlina Binti Morshidi/JMSK/PKS

Trees Neither
Complete
Full and Complete Binary Tree
nor full
Full but not
complete

Complete Full and
but not full complete

Azlina Binti Morshidi/JMSK/PKS

Azlina Binti Morshidi
JMSK PKS


Click to View FlipBook Version