Professional Documents
Culture Documents
Ds 11 Tree
Ds 11 Tree
Ds 11 Tree
Chapter 10
An Khuong, Le Hong
Trang
Trees
Discrete Structures for Computing on February 22, 2021
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Huynh Tuong Nguyen, Tran Tuan Anh, Nguyen An Khuong, Le Kruskal's Algorithm
Hong Trang
Faculty of Computer Science and Engineering
University of Technology - VNUHCM
trtanh@hcmut.edu.vn - htnguyen@hcmut.edu.vn
10.1
Contents Trees
1 Introduction
Properties of Trees
2 Tree Traversal
Contents
Introduction
3 Applications of Trees
Binary Search Trees
Properties of Trees
Tree Traversal
Decision Trees Applications of Trees
Binary Search Trees
Decision Trees
Prim's Algorithm
Kruskal's Algorithm
Kruskal's Algorithm
10.2
Course outcomes Trees
L.O.2 Represent and model practical problems with discrete structures Contents
L.O.2.1 Logically describe some problems arising in Computing Introduction
L.O.2.2 Use proving methods: direct, contrapositive, induction Properties of Trees
Decision Trees
10.3
Introduction Trees
/ Introduction
Properties of Trees
Tree Traversal
Decision Trees
Spanning Trees
tan mail ls junk Minimum Spanning
Trees
Prim's Algorithm
10.4
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
circuit exists Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
circuit exists Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
circuit exists Minimum Spanning
Trees
not connected Prim's Algorithm
Kruskal's Algorithm
10.5
Tree Trees
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
G1 G2 G3 G4 Spanning Trees
circuit exists Minimum Spanning
Trees
not connected Prim's Algorithm
Kruskal's Algorithm
Definition
10.5
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d Binary Search Trees
b Decision Trees
Spanning Trees
e Minimum Spanning
Trees
a Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d Binary Search Trees
b Decision Trees
Spanning Trees
e Minimum Spanning
Trees
a Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d Binary Search Trees
b Decision Trees
Spanning Trees
e Minimum Spanning
Trees
a Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b Binary Search Trees
b c Decision Trees
d Spanning Trees
e Minimum Spanning
Trees
a Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b Binary Search Trees
b c Decision Trees
d Spanning Trees
e Minimum Spanning
Trees
a f g Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b Binary Search Trees
b c Decision Trees
d Spanning Trees
e Minimum Spanning
Trees
a f g e Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b Binary Search Trees
b c Decision Trees
d Spanning Trees
e Minimum Spanning
Trees
a f g e Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b Binary Search Trees
b c Decision Trees
d Spanning Trees
e Minimum Spanning
Trees
a f g e Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b a Binary Search Trees
b c Decision Trees
d e Spanning Trees
e Minimum Spanning
Trees
a f g e Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b a Binary Search Trees
b c Decision Trees
d e Spanning Trees
e b Minimum Spanning
Trees
a f g e d Prim's Algorithm
Kruskal's Algorithm
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b a Binary Search Trees
b c Decision Trees
d e Spanning Trees
e b Minimum Spanning
Trees
a f g e d Prim's Algorithm
Kruskal's Algorithm
c f g
10.6
Rooted Trees Trees
Definition
Tree Traversal
Applications of Trees
d b a Binary Search Trees
b c Decision Trees
d e Spanning Trees
e b Minimum Spanning
Trees
a f g e d Prim's Algorithm
Kruskal's Algorithm
c f g
10.6
Terminology Trees
from the root to this vertex (excluding the vertex itself) Introduction
Properties of Trees
• descendants (con ch¡u) of a vertex v are those vertices that Tree Traversal
Decision Trees
a Spanning Trees
Minimum Spanning
Trees
b Prim's Algorithm
Kruskal's Algorithm
c
d
f g e
10.7
Terminology Trees
Definition
a Tree Traversal
Applications of Trees
Binary Search Trees
b Decision Trees
c Spanning Trees
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
10.8
Terminology Trees
Definition
Tree Traversal
b Applications of Trees
c Binary Search Trees
d Decision Trees
Spanning Trees
Minimum Spanning
g e Trees
f Prim's Algorithm
Kruskal's Algorithm
10.9
m-ary tree
Trees
Definition Trang
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Kruskal's Algorithm
10.10
Ordered Rooted Trees Trees
•
where the children of each internal vertex are ordered (e.g. in
order from left to right).
Contents
Introduction
Properties of Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
b c Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
e Kruskal's Algorithm
f d
g
Left subtree of a Right subtree of a
10.11
Ordered Rooted Trees Trees
•
where the children of each internal vertex are ordered (e.g. in
order from left to right).
• In an ordered binary tree (c¥y nhà ph¥n câ thù tü), if an
internal vertex has two children, the first child is called the
left child (con b¶n tr¡i ) and the second is called the right Contents
Introduction
child (con b¶n ph£i ). Properties of Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
b c Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
e Kruskal's Algorithm
f d
g
Left subtree of a Right subtree of a
10.11
Properties & Theorems Trees
Theorem
Theorem Contents
Introduction
A full m-ary tree Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.12
Properties & Theorems Trees
Theorem
Theorem Contents
Introduction
A full m-ary tree Properties of Trees
Spanning Trees
leaves
Minimum Spanning
(iii) ` leaves has n = (m` − 1)/(m − 1) vertices and
Trees
Kruskal's Algorithm
10.12
Example Trees
Tree Traversal
but did not send it out ? Applications of Trees
• How many people sent out the letter? Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.13
Example Trees
Tree Traversal
but did not send it out ? Applications of Trees
• How many people sent out the letter? Binary Search Trees
Decision Trees
Spanning Trees
Solution
Minimum Spanning
Trees
• Using 4-ary tree with 100 leaves corresponding to 100 persons
Prim's Algorithm
Kruskal's Algorithm
10.13
Level and Height Trees
Tree Traversal
a
Applications of Trees
Example
Binary Search Trees
Decision Trees
b k
• Level of root a = 0, Spanning Trees
b, j, k = 1 and
j Minimum Spanning
Trees
c f l c, e, f, l = 2 . . . Prim's Algorithm
e
Because the largest
Kruskal's Algorithm
•
g level of any vertex is
d i m n
4, this tree has height
4.
h
10.14
Balanced m-ary Trees Trees
Definition
Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
T1 Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
T2
10.15
Balanced m-ary Tree Trees
Theorem
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.16
Balanced m-ary Tree Trees
Theorem
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.16
Balanced m-ary Tree Trees
Theorem
Tree Traversal
Corollary
Applications of Trees
• If an m-ary tree of height h has ` leaves, then h ≥ dlogm `e.
Binary Search Trees
Decision Trees
• If the m-ary tree is full and balanced, then h = dlogm `e. Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.16
Exercise Trees
Tree Traversal
Exercise (Isomorphic) Applications of Trees
Decision Trees
• C6 H14
10.17
Question Trees
Exercise
• How many vertices and how many leaves does a complete Contents
m-ary tree of height h have? Introduction
• Tree Traversal
of height h has more than mh−1 leaves. Applications of Trees
• Decision Trees
Kruskal's Algorithm
10.18
Labeling Ordered Rooted Trees Trees
Tree Traversal
Applications of Trees
1 2 3 Binary Search Trees
Decision Trees
Spanning Trees
1.1 1.2 1.3 3.1 Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
1.3.1
1.1.1 1.3.2 3.1.1 3.1.2
1.3.1.1
10.19
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f g d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f g d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f g d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f g c d
10.20
Traversal Algorithms (Thuªt to¡n duy»t c¥y) Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
Minimum Spanning
d Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
a b f g c e d
10.20
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b g a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b g a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b g a d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b g a e d
10.21
Traversal Algorithms Trees
Tree Traversal
Applications of Trees
Binary Search Trees
b c Decision Trees
d Spanning Trees
Minimum Spanning
Trees
f g e Prim's Algorithm
Kruskal's Algorithm
f b g a e c d
10.21
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
d
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g b d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g b d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g b d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g b e d a
10.22
Traversal Algorithms Trees
Tree Traversal
a
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
b c
d Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
f g e
f g b e c d a
10.22
Infix, Prefix and Postfix Notations Trees
• Infix (trung tè ):
((x + y) ↑ 2) + ((x − 4)/3) +
Contents
↑ / Introduction
Prefix (ti·n tè ):
Properties of Trees
• Tree Traversal
+ ↑ +xy2/ − x43 + 2 − 3 Applications of Trees
Binary Search Trees
Decision Trees
x y x 4 Spanning Trees
Kruskal's Algorithm
10.23
Exercise Trees
Then use this rooted tree to find the prefix, postfix and infix forms Contents
of this expression Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.24
Exercise Trees
Then use this rooted tree to find the prefix, postfix and infix forms Contents
of this expression Introduction
Properties of Trees
Tree Traversal
Solution
Applications of Trees
• Constructing the rooted tree from the bottom up Binary Search Trees
Decision Trees
Kruskal's Algorithm
p q ∧ ¬ ∨ q¬r ∧ p¬r¬∨ →
• Inorder traversal creates infix notation (with parentheses)
p q¬ ∨ q¬ ∧ r → p¬ ∨ r¬
10.24
Exercise Trees
Exercise
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.25
Exercise Trees
Exercise
Tree Traversal
Applications of Trees
B Binary Search Trees
Decision Trees
C Spanning Trees
D E F G Minimum Spanning
Trees
Prim's Algorithm
H I J K Kruskal's Algorithm
Post order: D H I E B F J K G C A.
10.25
Exercise Trees
Exercise
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.26
Exercise Trees
Exercise
Tree Traversal
Applications of Trees
Binary Search Trees
D Decision Trees
B C Spanning Trees
E F G Minimum Spanning
Trees
Prim's Algorithm
J H I Kruskal's Algorithm
In-order: E D J B A H F I C G.
10.26
Exercise Trees
Exercise
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.27
Exercise Trees
Exercise
A Tree Traversal
Applications of Trees
B Binary Search Trees
Decision Trees
D
Spanning Trees
Minimum Spanning
E G F Trees
C Prim's Algorithm
Kruskal's Algorithm
K J H I
Pre-order: E D J B A H F I C G.
10.27
Binary Search Trees Trees
Definition
Binary search tree (c¥y t¼m ki¸m nhà ph¥n - BST) is a binary tree
in which the assigned key of a vertex is:
• larger than the keys of all vertices in its left subtree, and
• smaller than the keys of all vertices in its right subtree. Contents
Introduction
Properties of Trees
6 Tree Traversal
Applications of Trees
Binary Search Trees
2 7 Decision Trees
Spanning Trees
Minimum Spanning
Trees
1 4 9 Prim's Algorithm
Kruskal's Algorithm
3 5 8
10.28
Adding and Locating an Item in BST Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
zoology
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
meteorology zoology
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Spanning Trees
Minimum Spanning
Trees
psychology Prim's Algorithm
Kruskal's Algorithm
10.29
Adding and Locating an Item in BST Trees
Spanning Trees
Minimum Spanning
Trees
psychology Prim's Algorithm
Kruskal's Algorithm
Complexity in searching
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
lig
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
lig lig
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 Kruskal's Algorithm
lig
1
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 Kruskal's Algorithm
lig lig
1 2
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 7 8 Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 7 8 Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 7 8 4 5 Kruskal's Algorithm
10.30
Decision Trees (C¥y quy¸t ành) Trees
There are seven coins, all with the same weight, and a counterfeit
coin that weighs less than the others. How many weighings are
necessary using a balance scale to determine which of the eight
coins is the counterfeit one? Give an algorithm for finding this
counterfeit coin. Contents
Introduction
Properties of Trees
1 2 3 4 5 6 Tree Traversal
Applications of Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
1 2 7 8 4 5 Kruskal's Algorithm
10.30
Yet Another Application Trees
Example Trang
Tree Traversal
Applications of Trees
Binary Search Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
5 TB
Tree Traversal
0 0
0.0
Applications of Trees
Binary Search Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
5 TB
Tree Traversal
0 0
0.0
Applications of Trees
Start! 0.999
Binary Search Trees
Decision Trees
5 Spanning Trees
Minimum Spanning
Trees
TB Prim's Algorithm
Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
0.999
Introduction
+ Properties of Trees
5 TB
Tree Traversal
0 0
0.0
Applications of Trees
Start! 0.999
Binary Search Trees
Decision Trees
5 Spanning Trees
Minimum Spanning
Trees
TB Prim's Algorithm
Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
0.999
Introduction
+
0
Properties of Trees
5 TB .001
Tree Traversal
0 0
0.0
Applications of Trees
−
Start! 0.999
Binary Search Trees
Decision Trees
5 Spanning Trees
Minimum Spanning
Trees
TB Prim's Algorithm
Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
0.999
Introduction
+
0
Properties of Trees
5 TB .001
Tree Traversal
0 0
0.0
Applications of Trees
−
Start! 0.999
Binary Search Trees
Decision Trees
5 0.01 +
Spanning Trees
Minimum Spanning
TB 0.99 Trees
Prim's Algorithm
− Kruskal's Algorithm
10.31
Yet Another Application Trees
Example Trang
5 TB .001
Tree Traversal
0 0 TB & − = 0.0000005
0.0
Applications of Trees
−
Start! 0.999
Binary Search Trees
Decision Trees
10.31
Yet Another Application Trees
Example Trang
5 TB .001
Tree Traversal
0 0 TB & − = 0.0000005
0.0
Applications of Trees
−
Start! 0.999
Binary Search Trees
Decision Trees
p(TB∩+) 0.0004995
p(TB|+) = p(+) = 0.0004995+0.009995 ≈ 0.0476
10.31
Problem Trees
Definition
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.32
Problem Trees
Definition
a b c d Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
e g Spanning Trees
f Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.32
Problem Trees
Definition
a b c d Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
e g Spanning Trees
f Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.32
Problem Trees
Definition
a b c d Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
e g Spanning Trees
f Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.32
Problem Trees
Definition
a b c d Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
e g Spanning Trees
f Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.32
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
Start!
1
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
End!
1
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search (T¼m ki¸m ÷u ti¶n chi·u s¥u) Trees
2 3 4 Contents
Introduction
Properties of Trees
Tree Traversal
5 6 7 8 Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Property Minimum Spanning
Trees
• Go deeper as you can Prim's Algorithm
Kruskal's Algorithm
10.33
Depth-First Search Trees
Algorithm
visit (v1 )
Introduction
Properties of Trees
Tree Traversal
procedure visit (v : vertex of G) /* recursive */ Applications of Trees
Decision Trees
Kruskal's Algorithm
10.34
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1
Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
Start! ∅
1 1
Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
Start! ∅
1 1 2, 3, 4
Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4
Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6 Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4 5 6, 7, 8
Properties of Trees
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4 5 6, 7, 8
Properties of Trees
Tree Traversal
6 7, 8 Applications of Trees
Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4 5 6, 7, 8
Properties of Trees
Tree Traversal
6 7, 8 Applications of Trees
7 8 Binary Search Trees
Decision Trees
5 6 7 8 Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4 5 6, 7, 8
Properties of Trees
Tree Traversal
6 7, 8 Applications of Trees
8
Decision Trees
5 6 7 8 ∅ Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.35
Breadth-First Search (T¼m ki¸m ÷u ti¶n chi·u rëng) Trees
vertex L
∅
1 1 2, 3, 4
2 3, 4, 5, 6
3 4, 5, 6 Contents
4 5, 6, 7, 8 Introduction
2 3 4 5 6, 7, 8
Properties of Trees
Tree Traversal
6 7, 8 Applications of Trees
7 8 Binary Search Trees
8
Decision Trees
5 6 7 8 ∅ Spanning Trees
Minimum Spanning
Trees
Property Prim's Algorithm
Kruskal's Algorithm
• O(e) or O(n2 )
10.35
Breadth-First Search Trees
Algorithm
Decision Trees
Kruskal's Algorithm
10.36
Exercise Trees
Contents
d e f g Introduction
Properties of Trees
Tree Traversal
Applications of Trees
h i j Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.37
Exercise Trees
Contents
d e f g Introduction
Properties of Trees
Tree Traversal
Applications of Trees
h i j Binary Search Trees
Decision Trees
a b c Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
d e f g Kruskal's Algorithm
h i
10.37
Minimum Spanning Trees Trees
Definition
Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.38
Minimum Spanning Trees Trees
Definition
00
$1600
$8
Prim's Algorithm
0 Kruskal's Algorithm
$140
0
$220 Atlanta
0
10.38
Minimum Spanning Trees Trees
Definition
00
$1600
$8
Prim's Algorithm
0 Kruskal's Algorithm
$140
0
$220 Atlanta
0
10.38
Prim's Algorithm (Nearest-Neighbor) Trees
Tree Traversal
e := an edge of minimum weight incident to a vertex in T Applications of Trees
and not forming a simple circuit in T if added to T Binary Search Trees
T := T with e added
Decision Trees
Spanning Trees
return T Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.39
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
1 4 1
Tree Traversal
10 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
1 4 1
Tree Traversal
10 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
1 4 1
Tree Traversal
10 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
4 Tree Traversal
1 10 1 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
4 Tree Traversal
1 10 1 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
4 Tree Traversal
1 10 1 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
4 Tree Traversal
1 10 1 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Prim's Algorithm (Nearest-Neighbor) Trees
a 4 b 5 c Contents
Introduction
Properties of Trees
4 Tree Traversal
1 10 1 Applications of Trees
Binary Search Trees
Decision Trees
d e Spanning Trees
Minimum Spanning
Trees
5 10 Prim's Algorithm
3 Kruskal's Algorithm
f 10 g
10.40
Kruskal's Algorithm (Lightest-Edge) Trees
Tree Traversal
e := any edge in G with smallest weight that does not form Applications of Trees
a simple circuit when added to T Binary Search Trees
T := T with e added
Decision Trees
Spanning Trees
return T Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.41
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Kruskal's Algorithm (Lightest-Edge) Trees
a 4 b 5 c
Contents
Introduction
1 4 1
Properties of Trees
Tree Traversal
10 Applications of Trees
Binary Search Trees
d e Decision Trees
Spanning Trees
5 10
Minimum Spanning
Trees
3 Prim's Algorithm
Kruskal's Algorithm
f 10 g
10.42
Exercise Trees
Exercise
. Tree Traversal
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.43
Exercise Trees
Exercise
4
Properties of Trees
a b c Tree Traversal
1 2 5 2 4 1 Applications of Trees
Binary Search Trees
d e 2 f g Decision Trees
1 Spanning Trees
2 3 1 3 1 Minimum Spanning
Trees
Prim's Algorithm
h i j Kruskal's Algorithm
10.43
Exercise Trees
Exercise
1 8
Properties of Trees
a b c Tree Traversal
4 2 4 6 1 2 Applications of Trees
Binary Search Trees
Decision Trees
d e f g
5 1 3 Spanning Trees
3 2 7 Minimum Spanning
Trees
Prim's Algorithm
h i Kruskal's Algorithm
10.43
Exercise Trees
Exercise
Tree Traversal
3 1 2 5 Applications of Trees
4 3 3
Binary Search Trees
f g Decision Trees
e h Spanning Trees
Minimum Spanning
4 2 4 3 Trees
3 3 1
Prim's Algorithm
Kruskal's Algorithm
i j k l
10.43
Exercise Trees
Exercise
Tree Traversal
3 1 2 5 Applications of Trees
4 3 3
Binary Search Trees
f g Decision Trees
e h Spanning Trees
Minimum Spanning
4 2 4 3 Trees
3 3 1
Prim's Algorithm
Kruskal's Algorithm
i j k l
10.43
Exercise Trees
Given a rooted tree has n verticies. Suppose that degree of every Contents
vertex is n − 1. Which is the height of the tree? Introduction
Properties of Trees
A) 1 Tree Traversal
Applications of Trees
B) n−1 Binary Search Trees
Decision Trees
C) n Spanning Trees
D) 2 Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.44
Exercise Trees
Tree Traversal
A) → ∨¬ ∧ p q ∨ ¬q r ∨ ¬p r Applications of Trees
Binary Search Trees
Spanning Trees
C) p q¬ ∨ q¬ ∧ r → p¬ ∨ r Minimum Spanning
Trees
D) p q¬ ∨ q¬ ∧ r → p¬ ∨ r Prim's Algorithm
Kruskal's Algorithm
10.45
Exercise Trees
A) 1 Tree Traversal
Applications of Trees
B) 3 Binary Search Trees
Decision Trees
C) 5 Spanning Trees
D) 7 Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.46
Exercise Trees
Tree Traversal
A) GF BCIEADH Applications of Trees
B) BGF DECIAH Binary Search Trees
Decision Trees
Kruskal's Algorithm
10.47
Exercise Trees
graph below?
8 14
32 Contents
2 12 Introduction
24 26 Properties of Trees
Tree Traversal
18 28 Applications of Trees
Binary Search Trees
Decision Trees
16 30 4 Spanning Trees
22
Minimum Spanning
Trees
.
Prim's Algorithm
10 20 Kruskal's Algorithm
A) 40
B) 60
C) 84
D) 100 10.48
Revision Trees
2 3 B C
An Khuong, Le Hong
Trang
1 4 A D Contents
Introduction
Properties of Trees
Tree Traversal
Applications of Trees
6 5
Binary Search Trees
F E Decision Trees
A) G is a tree.
Tree Traversal
c) + - ∗ 3 2 + 2 3 / 6 - 4 2 Applications of Trees
d) * + 3 + 3 ∗ 3 + 3 3 3
Binary Search Trees
Decision Trees
Spanning Trees
Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.50
Revision Trees
Find the minimum spanning tree of the graph below (using both Tran Tuan Anh, Nguyen
An Khuong, Le Hong
A 11 C 5 E
10
6 2 2 4
S 10 Contents
B 8 D 7 F 8
Introduction
Properties of Trees
H Tree Traversal
14 3 4 6
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
G Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
10.51
Revision Trees
Find the minimum spanning tree of the graph below (using both Tran Tuan Anh, Nguyen
An Khuong, Le Hong
A 11 C 5 E
10
6 2 2 4
S 10 Contents
B 8 D 7 F 8
Introduction
Properties of Trees
H Tree Traversal
14 3 4 6
Applications of Trees
Binary Search Trees
Decision Trees
Spanning Trees
G Minimum Spanning
Trees
Prim's Algorithm
Kruskal's Algorithm
khung hay bao tròm, spanning tree ) cõa K2a+3 l bao nhi¶u? Introduction
Properties of Trees
Tree Traversal
A) 2a + 2 Applications of Trees
2 Binary Search Trees
B) 2a + 3a − 1 Decision Trees
Kruskal's Algorithm
10.52
Revision Trees
Gåi T l c¥y bao tròm cõa ç thà ¦y õ K6 . Sè l÷ñng c¤nh cõa Tree Traversal
Decision Trees
A) 5
Spanning Trees
B) 10 Minimum Spanning
Trees
C) 15 Prim's Algorithm
Kruskal's Algorithm
D) 20
10.53