Discrete Mathematics and Its Applications: Chapter 9 - Trees, Study notes of Discrete Structures and Graph Theory

This chapter from 'discrete mathematics and its applications' by kenneth h. Rosen introduces the concept of trees in graph theory. A tree is a connected, undirected graph with no cycles. The chapter covers rooted trees, properties of trees, binary search trees, decision trees, prefix codes, and tree traversal. Exercises are provided at the end of each section.

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-egn
koofers-user-egn 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DISCRETE MATHEMATICS AND ITS APPLICATIONS
by Kenneth H. Rosen
Chapter 9 -- Trees
9.1 Introduction
A tree is a connected undirected graph with no simple circuits (cycles).
An undirected graph is a tree iff there is a unique simple path between any two of its
vertices.
A rooted tree is a directed graph constructed from a tree with one vertex designated as a
root, and each edge directed away from the root.
In a rooted tree T, let (u, v) be a directed edge in T, then u is the parent of v, and v the child
of u; vertices with the same parents are called siblings; the ancestors of a vertex v other than
the root are the vertices in the path from the root to v; the descendants of a vertex v are those
vertices that have v as an ancestor; a leaf is a vertex with no children; vertices that have
children are called internal vertices; a vertex v together with its descendants and all edges
incident to these descendants form a subtree.
A rooted tree where every internal vertex has m children is called an m-ary tree; it is a
binary tree if m = 2.
The level of a vertex v in a rooted tree is the length of the unique path from the root to v.
The height of a rooted tree is the maximum of the levels of vertices.
A rooted m-ary tree of height h is called balanced if all leaves are at levels h or h-1.
In an ordered rooted tree the children of each internal vertex are ordered. If a 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 is called the left subtree, and that rooted at the right
child is called the right subtree.
Trees may be used to model:
Saturated hydrocarbons
Organizations
File directories
Interconnection networks for parallel processing
Properties of trees
A tree with n vertices has exactly n 1 edges.
A full m-ary tree with i internal vertices contains n = mi + 1 vertices.
A full m-ary tree with
n vertices has i = (n1)/m internal vertices and l = [(m1)n + 1]/m leaves.
i internal vertices has n = m i + 1 vertices and l = (m1)i + 1 leaves.
l leaves has n = (ml1)/(m1) vertices and i = (l1)/(m1) internal vertices.
There are at most mh leaves in an m-ary tree of height h.
If an m-ary tree of height h has l leaves, then h logm l . If the m-ary tree is full and
balanced, then h = logm l .
Exercises in 9.1
pf3

Partial preview of the text

Download Discrete Mathematics and Its Applications: Chapter 9 - Trees and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!

DISCRETE MATHEMATICS AND ITS APPLICATIONS

by Kenneth H. Rosen Chapter 9 -- Trees 9.1 Introduction  A tree is a connected undirected graph with no simple circuits (cycles).  An undirected graph is a tree iff there is a unique simple path between any two of its vertices.  A rooted tree is a directed graph constructed from a tree with one vertex designated as a root , and each edge directed away from the root.  In a rooted tree T, let ( u , v ) be a directed edge in T, then u is the parent of v , and v the child of u ; vertices with the same parents are called siblings ; the ancestors of a vertex v other than the root are the vertices in the path from the root to v ; the descendants of a vertex v are those vertices that have v as an ancestor; a leaf is a vertex with no children; vertices that have children are called internal vertices ; a vertex v together with its descendants and all edges incident to these descendants form a subtree.  A rooted tree where every internal vertex has  m children is called an m - ary tree ; it is a binary tree if m = 2.  The level of a vertex v in a rooted tree is the length of the unique path from the root to v.  The height of a rooted tree is the maximum of the levels of vertices.  A rooted m-ary tree of height h is called balanced if all leaves are at levels h or h -1.  In an ordered rooted tree the children of each internal vertex are ordered. If a 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 is called the left subtree , and that rooted at the right child is called the right subtree.  Trees may be used to model:  Saturated hydrocarbons  Organizations  File directories  Interconnection networks for parallel processing  Properties of trees  A tree with n vertices has exactly n  1 edges.  A full m-ary tree with i internal vertices contains n = mi + 1 vertices.  A full m-ary tree with  n vertices has i = ( n 1)/ m internal vertices and l = [( m 1) n + 1]/ m leaves.  i internal vertices has n = mi + 1 vertices and l = ( m 1) i + 1 leaves.  l leaves has n = ( ml 1)/( m 1) vertices and i = ( l 1)/( m 1) internal vertices.  There are at most m h leaves in an m-ary tree of height h.  If an m-ary tree of height h has l leaves, then h   log m l . If the m-ary tree is full and balanced, then h =  log m l . Exercises in 9.

9.2 Applications of TreesBinary search tree -- an ordered rooted binary tree in which each vertex is labeled with a key that 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.  Binary Search Tree Algorithm (see Algorithm 1 in §8.2)  Decision tree -- A rooted tree in which each internal vertex corresponds to a decision, with a subtree at these vertices for each possible outcomes of the decision.  Example: Finding Counterfeit Coin  Prefix codes -- codes based on an encoding scheme where bit strings of different lengths are used to encode letters, with the property that the bit string for a letter does not occur as the prefix of any other letter. The objective is to save in the overall memory and reduce transmittal time for the coded data.  Huffman Coding Algorithm Construct a binary tree recursively given weights w 1  w 2   w n as follows:

  1. Create a tree with subtree rooted at the 2 smallest weights. Their combined weights become the weights of the root of this subtree, which will be used with the remaining weights for the construction of other branches.
  2. Repeat step 1 until all weights are combined.
  3. The 2 branches of each internal vertex are labeled 0 and 1. Each letter gets the path of labels as obtained in the binary tree. Exercises in 9. 9.3 Tree TraversalPreorder traversal (results in depth-first search, or backtracking)
  4. Visit the root.
  5. Visit the left subtree, using preorder.
  6. Visit the right subtree, using preorder.  Inorder traversal
  7. Visit the left subtree, using inorder.
  8. Visit the root.
  9. Visit the right subtree, using inorder.  Postorder traversal (results in the Reversed Polish Notation when used for algebraic expressions)
  10. Visit the left subtree, using postorder.
  11. Visit the right subtree, using postorder.
  12. Visit the root. Exercises in 9. 9.4 & 9.5 Spanning Trees and Minimum Spanning Trees