

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 3
This page cannot be seen from the preview
Don't miss anything!


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 = m i + 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 = m i + 1 vertices and l = ( m 1) i + 1 leaves. l leaves has n = ( m l 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 Trees Binary 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: