ch7 Trees
ch7 Trees
ch7 Trees
Johnsonbaugh
Discrete
Mathematics
5th edition, 2001
Chapter 7
Trees
7.1 Introduction
A (free) tree T is
A simple graph
such that for
every pair of
vertices v and w
there is a unique
path from v to w
Rooted tree
Example:
the tree on the right has height
3
Organizational charts
Huffman codes
Parent
Ancestor
Child
Descendant
Siblings
Terminal vertices
Internal vertices
Subtrees
Internal and external vertices
An internal vertex is a
vertex that has at least
one child
A terminal vertex is a
vertex that has no
children
The tree in the example
has 4 internal vertices and
4 terminal vertices
Subtrees
Theorem 7.2.3
If T is a graph with n vertices, the following
are equivalent:
a) T is a tree
b) T is connected and acyclic
(“acyclic” = having no cycles)
c) T is connected and has n-1 edges
d) T is acyclic and has n-1 edges
7.3 Spanning trees
Breadth-first search
method
Depth-first search
method
(backtracking)
7.4 Minimal spanning trees
Theorem 7.5.6: If a
binary tree of height h
has t terminal vertices,
then lg t < h, where lg is
logarithm base 2.
Equivalently, t < 2h.
Example, h = 4 and t = 7.
Then: t = 7 < 16 = 24 = 2h
A case of equality
1: Pre-order
traversal
2: In-order traversal
More on tree traversals
3: Post-order traversal
4: Reverse post-order
traversal
Arithmetic expressions
Standard: infix form
(A+B) C – D/ E
Fully parenthesized form (in
-order & parenthesis):
(((A + B) C) – (D / E))
Postfix form (reverse Polish
notation):
A B + C D E / -
Prefix form (Polish notation):
- + A B C / D E
7.7 Decision trees
Theorem 7.8.12:
There are C(2n,n) / (n+1) non-isomorphic
binary trees with n vertices, n > 0, where
C(2n,n) / (n+1) are the Catalan numbers Cn
Catalan numbers (1)