You are on page 1of 9

Discrete mathematics 2 Exercises 12

Trees: Introduction, models and properties

Definition: A tree is a connected undirected graph with no simple circuits. Because a tree
cannot have a simple circuit, a tree cannot contain multiple edges or loops. Therefore any
tree must be a simple graph.

Definition: Graphs containing no simple circuits that are not necessarily connected are
called forests and have the property that each of their connected components is a tree.

Theorem 1: An undirected graph is a tree if and only if there is a unique simple path
between any two of its vertices.

Definition: A rooted tree is a tree in which one vertex has been designated as the root
and every edge is directed away from the root. We usually draw a rooted tree with its
root at the top of the graph. The arrows indicating the directions of the edges in a rooted
tree can be omitted, because the choice of root determines the directions of the edges.

Definition: Suppose that T is a rooted tree. If v is a vertex in T other than the root, the
parent of v is the unique vertex u such that there is a directed edge from u to v. When u
is the parent of v, v is called a child of u. Vertices with the same parent are called siblings.
The ancestors of a vertex other than the root are the vertices in the path from the root
to this vertex, excluding the vertex itself and including the root (that is, its parent, its
parent’s parent, and so on, until the root is reached). The descendants of a vertex v are
those vertices that have v as an ancestor.
A vertex of a rooted tree is called a leaf if it has no children. Vertices that have children
are called internal vertices. The root is an internal vertex unless it is the only vertex in the
graph, in which case it is a leaf.

Definition: If a is a vertex in a tree, the subtree with a as its root is the subgraph of the
tree consisting of a and its descendants and all edges incident to these descendants.

Definition: A rooted tree is called an m-ary tree if every internal vertex has no more than
m children. The tree is called a full m-ary tree if every internal vertex has exactly m
children. An m-ary tree with m = 2 is called a binary tree.

Definition: An ordered rooted tree is a rooted tree where the children of each internal
vertex are ordered. Ordered rooted trees are drawn so that the children of each internal
vertex are shown in order from left to right. In an ordered binary tree (usually called just
a binary tree), if an internal vertex has two children, the first child is called the left child
and the second child is called the right child. The tree rooted at the left child of a vertex
is called the left subtree of this vertex, and the tree rooted at the right child of a vertex is
called the right subtree of the vertex.

1
Discrete mathematics 2 Exercises 12
Definition: The level of a vertex v in a rooted tree is the length of the unique path from
the root to this vertex. The level of the root is defined to be zero. The height of a rooted
tree is the maximum of the levels of vertices. In other words, the height of a rooted tree
is the length of the longest path from the root to any vertex.

Theorem 2: A tree with n vertices has n − 1 edges.

Theorem 3: A full m-ary tree with i internal vertices contains n = mi + 1 vertices.

Theorem 4: A full m-ary tree with


(i ) n vertices has i = (n − 1)/m internal vertices and l = [(m − 1)n + 1]/m leaves,
(ii ) i internal vertices has n = mi + 1 vertices and l = (m − 1)i + 1 leaves,
(iii ) l leaves has n = (ml − 1)/(m − 1) vertices and i = (l − 1)/(m − 1) internal vertices.

Definition: A rooted m-ary tree of height h is balanced if all leaves are at levels h or h − 1.

Definition: A complete m-ary tree is a full m-ary tree in which every leaf is at the same
level.

Theorem 5: There are at most mh leaves in an m-ary tree of height h.

Corollary: If an m-ary tree of height h has l leaves, then h ≥ logml. If the m-ary tree is
full and balanced, then h = logml.

Exercises

Exercise 1. Which of the following graphs are trees?

2
Discrete mathematics 2 Exercises 12
Solution:
The graphs а), b), d) and f) are trees. The graph c) is not a tree since it is not connected.
The graph e) contains simple circuits.

Exercise 2. Answer these questions about the rooted tree illustrated.


a) Which vertex is the root?
b) Which vertices are internal?
c) Which vertices are leaves?
d) Which vertices are children of j?
e) Which vertex is the parent of h?
f ) Which vertices are siblings of o?
g) Which vertices are ancestors of m?
h) Which vertices are descendants of b?

Solution:
a) a. b) a, b, d, e, g, h, i and o; c) c, f, j, k, l, m, n, p, q, r and s;
d) The vertex j is a leaf, so it doesn’t have any children.
e) d. f ) Only p. g) g, b and a;
h) e, f, g, j, k, l and m.

Exercise 3. Is the rooted tree in Exercise 2 a full m-ary tree for some positive integer m?
Solution:
No. For example, the vertices g and b have different number of children. In a complete
tree all internal vertices should have the same number of children.

Exercise 4. What is the level of each vertex of the rooted tree in Exercise 2? What is the
height of the tree?
Solution:
The level of the root a is 0; the level of b, c and d is 1; the level of e, f, g, h and i is 2;
the level of j, k, l, m, n, o and p is 3; the level of q, r and s is 4. The height of the tree is
4.

Exercise 5. Draw the subtree of the tree in Exercise 3 that is rooted at


a) a; b) c; c) e;
Solution:

3
Discrete mathematics 2 Exercises 12

а) b) c)

Exercise 6. What does each of these represent in rooted tree representing a computer
file system?
a) the parent of a vertex
b) a child of a vertex
c) a sibling of a vertex
d) the ancestors of a vertex
e) the descendants of a vertex
f ) the level of a vertex
g) the height of the tree

The root is the root directory l


The internal vertices are directories
The leaves are files

Solution:
a) the parent directory
b) subdirectory or file contained in the directory
c) subdirectory or file in the same parent directory
d) all the directories in the name of the path
e) all directories or files that have the current directory in their path name
f ) the length of the pathname

4
Discrete mathematics 2 Exercises 12
g) the length of the longest pathname

Exercise 7. The rooted Fibonacci trees Tn are defined recursively in the following way. T1
and T2 are both the rooted tree consisting of a single vertex, and for n = 3, 4, . . . , the
rooted tree Tn is constructed from a root with Tn−1 as its left subtree and Tn−2 as its right
subtree.
Solution:

Exercise 8. How many edges does a tree with 10,000 vertices have?
Solution:
From Theorem 2, a tree with n = 10 000 vertices has n – 1 = 10 000 – 1 = 9 999 edges.

Exercise 9. а) How many nonisomorphic unrooted trees are there with three vertices?
b) How many nonisomorphic rooted trees are there with three vertices?

Solution:
а) 1; b) 2.

Exercise 10. Draw all the trees with 6 vertices up to isomorphism. (All of the drawn trees
are nonisomorphic to each other, but all the other trees of 6 vertices are isomorphic to
exactly one of them).
Solution:
A vertex in a tree of 6 vertices can have degree at most 5 (a bigger degree means that
there are more than 6 vertices in the graph). If a vertex has degree 5, then all the
edges connect the vertex to all of the other vertices. (the first graph in the picture). If
there is a vertex of degree 4 then it is connected to 4 other vertices, and the last one
is connected to one of the other vertices (the second graph in the picture). If there
are two vertices of degree 3, then they must be connected to each other (the third
graph). If the graph has exactly one vertex of degree 3, then it is connected to 3
different vertices, and the remaining 2 vertices are connected to each other, or to
different vertices (the fourth and the fifth graph). If there is no vertex of degree bigger
than 2, than stating from a vertex of degree 1, and traversing the graph through all of
the vertices of degree 2, we will end up in a vertex of degree 1. There is only one such
graph (the sixth graph in the picture).

1) 2) 3)

5
Discrete mathematics 2 Exercises 12

4) 5) 6)

Exercise 11. а) A given tree has two vertices of degree 4, one vertex of degree 3, one
vertex of degree 2, and the remaining vertices are of degree 1. How many vertices does
the tree have?
b) Draw the tree from а).
Solution:
а) Suppose the tree has n vertices, and suppose k of them are of degree 1. Hence it
is true that k + 1 + 1 + 2 = n ( k vertices are of degree 1, two vertices of degree 4, one
vertex of degree 3, one vertex of degree 2, and there are in total n vertices) and
1 ⋅ k + 2 ⋅ 1 + 3 ⋅ 1 + 4 ⋅ 2 = 2 ⋅ (n − 1) (there are in total n − 1 edges, which is half the sum
of the degrees of the vertices). From these two relations we get that k = 7 and
n = k + 4 = 11 ;
b) There are several graphs with these properties up to isomorphism.

Exercise 12. How many vertices are there in a full 5-ary tree with 100 internal vertices?
Solution:
From Theorem 3, a full m-ary tree with i internal vertices has n = mi + 1 vertices in
total. Hence n = 5 ∙ 100 + 1 = 501.

Exercise 13. How many vertices does a full binary tree with 1000 internal vertices have?
Solution:
From Theorem 3, a full m-ary tree with i internal vertices has n = mi + 1 vertices in
total. Hence n = 2 ∙ 1000 + 1 = 2001.

Exercise 14. Prove


a) part (ii) of Theorem 4.
b) part (iii) of Theorem 4.
Solution:
a) From Theorem 3, a full m-ary tree with i internal vertices has n = mi + 1 vertices in
total. Since i + l = n, we get that l = n – i, so l = (mi + 1) – i = (m – 1)i + 1;
b) From n = mi + 1 and i + l = n we get that i = n – l. Hence n = m(n – l) + 1, and further
n = (ml – 1)/(m – 1). From i = n – l, we get i = [(ml – 1)/(m – 1)] – l = (l – 1)/(m – 1).

Exercise 15. How many leaves does a full 3-ary tree with 100 vertices have?
Solution:

6
Discrete mathematics 2 Exercises 12
From Theorem 4, a full m-ary tree with n vertices has l = [(m – l)n + 1]/m leafs. Thus,
l = [(3 – l)∙100 + 1]/3 = 67.

Exercise 16. A chain letter starts when a person sends a letter to five others. Each person
who receives the letter either sends it to five other people who have never received it or
does not send it to anyone. Suppose that 10,000 people send out the letter before the
chain ends and that no one receives more than one letter. How many people receive the
letter, and how many do not send it out?
Solution:
The chain letter can be represented using a full 5-ary tree. The internal vertices
correspond to the people that sent out the letter, and the leafs to the people that did
not send out the letter. Thus, the tree has i = 10 000 internal vertices, so from Theorem
4, in total n = mi + 1 = 5 ∙ 10 000 + 1 = 50 001 vertices (the total number of people in
the chain). The letter was received by 50 000 people (all except the first), and was not
sent out by l = 50 001 – 10 000 = 40 001 (the number of leafs).

Exercise 17. а) Construct a complete binary tree of height 4;


b) Construct a complete 3-ary tree of height 3.
Solution:
a) b)

Exercise 18. How many vertices and how many leaves does a complete m-ary tree of
height h have?
Solution:
A complete m-ary tree of height h has mh leafs. Find the total number of vertices
yourself.

Supplementary exercises

Exercise 19. а) Show that every forest with n vertices and m components has n − m
edges;
b) Show that every graph with n vertices, m components and n − m edges, must be a
forest.
Solution:
а) Each component in the forest, is itself a tree. Hence if each of the components has
n1 , n2 , . . ., nm vertices, respectively, then each of them has n1 − 1 , n2 − 1 , . . ., nm − 1
edges respectively, and it holds that n1 + n2 + ... + nm = n , hence
n1 − 1 + n2 − 1 + ... + nm − 1 = n − m , i.e. the forest has exactly n − m edges.

7
Discrete mathematics 2 Exercises 12
b) Suppose the components of the graph have n1 , n2 , . . ., nm vertices respectively.
Each of them has at least n1 − 1 , n2 − 1 , . . ., nm − 1 edges respectively, hence in total
at least n1 − 1 + n2 − 1 + ... + nm − 1 = n − m edges. Equality holds when each of the
components has exactly ni − 1 edges, i.e. each of the components is a tree. Thus the
graph is a forest.

Exercise 20. Show that every tree can be colored using only two colors.
Solution:
Each of the vertices in the odd levels are colored in one color, and the vertices in the
even levels in the other color.

Exercise 21. Show that in a graph G = (T, R) the following conditions are equivalent:
(i) G is a tree;
(ii) Each two vertices are connected with a unique path;
(iii) G is connected and for each edge r ∈ R, k(G-r) = 2 (i.e. deleting an edge from the graph
gives a subgraph with two connected components);
(iv) G does not contain any circuits, and for each edge r ∈B(T) \ R, the graph G + r contains
a circuit.
Solution:
We will show (i) ⇒ (ii) ⇒ (iii) ⇒ (iv) ⇒ (i), which will imply the equivalence of the
four claims (i) - (iv).

(i) ⇒ (ii). If x,y ∈ Т are connected with two different paths, then connecting the paths
we will get a circuit which is not possible in a tree.
(ii) ⇒ (iii). Let r = {u, v} ∈ R, where u, v ∈ Т. If k(G-r) = 1, i.e. if G is connected, then
there is a path from u to v in G-r, which means that u and v are connected through
two paths in G. If k(G-r) = k > 2, i.e. G-r has k (>2) components, by adding the edge r in
G-r we get the graph G, and then G has k – 1 (>1) components (since r connects only
two components of G-r), which means G is not connected.
(iii) ⇒ (iv). r ∈ B(T) \ R and r = {x, y}, where x,y ∈ Т. Since G is connected, there is a
path in G from x to y, not passing through r, so this path, together with r, forms a
circuit in G + r.
(iv) ⇒ (i). Let G be connected, and let G1, G2, …, Gk be its components (k > 1), where
G1 = (T1, R1), G2 = (T2, R2). Each of these components has no circuits. We take x ∈ T1, y
∈ T2 and put T’ = T1 ∪ T2, R’ = R1 ∪ R2 ∪ {x, y} and G’ = (T’, R’). If r = {x, y}, then G + r
contains the components G’, G3, …, Gk, and then only G’ has a circuit, that contains
the edge r. But then G’–r is connected, and also with two components, which is
impossible.

Exercise 22. Let T be a tree with n vertices, n ≥ 2. For the integer i, let pi denote the number
of vertices of degree i in the tree T. Prove that
p1 – p3 – 2p4 – … – (n – 3)pn-1 = 2

8
Discrete mathematics 2 Exercises 12
Solution:
In an arbitrary graph G with n vertices, the sum of the degrees of the vertices is:
n −1

∑ d G (v) = ∑ ipi ,
v∈V ( G ) i =1

Clearly,
n −1

∑p i =1
i =n

Since G is a tree, the number of edges is n – 1, so:


n −1 n −1

∑ ip
i =1
i = 2(n − 1) = 2∑ pi − 2
i =1
Hence:
n −1

∑ (2 − i ) p
i =1
i = 2 , i.e. p1 – p3 – 2p4 – … – (n – 3)pn-1 = 2

Exercise 23. The king of Shongabanga had 4 sons. 10 of his male descendants had 3 sons
each, 15 of his male descendants had 2 sons each, while the rest died without any
children. Knowing that the king of Shongabanga did not have any female children,
determine the number of male descendants the king had?
Solution:
From the family tree of the king, we see that the root of the tree (the root) has degree
4, while the rest of the vertices (descendents) have degrees one more than the
number of sons.
Let pi denote the number of vertices of degree i. Then p3 = 15 and p4 = 10 + 1 = 11.
Since the tree contains only vertices of degrees 1, 3 or 4, from the previous exercise
p1 = p3 + 2p4 + 2 = 39, so the number of vertices is n = p1 + p3 + p4 = 65. This means that
there are 64 descendents.

You might also like