Chapter 11 Notes
Chapter 11 Notes
1
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.
11.1.1
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.
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 (the reader should show that such a vertex is unique). When u is the parent of v, v is
called a child of u.
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).
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.
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.
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.
11.1.3
A tree with n vertices has n − 1 edges.
This theorem tells us that the two conditions (i) G is connected and (ii) G has no simple circuits,
imply (iii) G has n − 1 edges.
Proof: Every vertex, except the root, is the child of an internal vertex. Because each of the i internal
vertices has m children, there are mi vertices in the tree other than the root. Therefore, the tree
contains n = mi + 1 vertices.
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
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.
11.2.2
Binary Search Tree: a binary tree in which each child of a vertex is designated as a right or left child, no
vertex has more than one right child or left child, and each vertex is labeled with a key, which is one of
the items. Furthermore, vertices are assigned keys so that the key of a vertex is both larger than the
keys of all vertices in its left subtree and smaller than the keys of all vertices in its right subtree.
1. Start with a tree containing just one vertex, namely, the root. The first item in the list is
assigned as the key of the root.
2. To add a new item, first compare it with the keys of vertices already in the tree, starting at
the root and moving to the left if the item is less than the key of the respective vertex if this
vertex has a left child, or moving to the right if the item is greater than the key of the
respective vertex if this vertex has a right child.
a. When the item is less than the respective vertex and this vertex has no left child, then a
new vertex with this item as its key is inserted as a new left child.
b. Similarly, when the item is greater than the respective vertex and this vertex has no
right child, then a new vertex with this item as its key is inserted as a new right child.
(A − B) − ((A - C) ∪ (B ∩ (A ∪ C)))
Prefix notation:
-∪∩∪ACB-AC-AB
+↑+xy2 /-x43
Postfix notation: