1 Section 9.1 Introduction to Trees. 2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph:

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

Chapter 9 Graphs.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
Introduction to Trees Chapter 6 Objectives
Data Structures: A Pseudocode Approach with C 1 Chapter 6 Objectives Upon completion you will be able to: Understand and use basic tree terminology and.
22C:19 Discrete Math Trees Fall 2011 Sukumar Ghosh.
1 Chapter 10 Trees. Tree Definition 1. A tree is a connected undirected graph with no simple circuits. Theorem 1. An undirected graph is a tree if and.
1 Copyright M.R.K. Krishna Rao 2003 Ch 9 - Trees Definition: A tree is a connected undirected graph with no simple circuits. Since a tree cannot have a.
Discrete Mathematics – CIS166
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
Section 3.1 Properties of Trees Sarah Graham. Tree Talk: Vocabulary oTree: a tree is a special type of graph that contains designated vertex called a.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
A tree is a simple graph satisfying: if v and w are vertices and there is a path from v to w, it is a unique simple path. a b c a b c.
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Trees.
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
CSC 2300 Data Structures & Algorithms February 6, 2007 Chapter 4. Trees.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Trees and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
COSC2007 Data Structures II
Trees. Introduction to Trees Trees are very common in computer science They come in different forms They are used as data representation in many applications.
Introduction Of Tree. Introduction A tree is a non-linear data structure in which items are arranged in sequence. It is used to represent hierarchical.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Introduction to Trees. When at a node in a singly linked list, there is no choice as to which node can be visited next: Motivation when here we can only.
Section 10.1 Introduction to Trees These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 6 th ed., by Kenneth.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
Foundations of Discrete Mathematics
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Trees – Chapter 9 Slides courtesy of Dr. Michael P. Frank University of Florida Dept. of Computer & Information Science & Engineering.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Discrete Structures Trees (Ch. 11)
Chap 8 Trees Def 1: A tree is a connected,undirected, graph with no simple circuits. Ex1. Theorem1: An undirected graph is a tree if and only if there.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Discrete Mathematics Chapter 5 Trees.
CS 103 Discrete Structures Lecture 23 Trees (1). Second Midterm Exam 1 st Lecture in December (same time as the lecture) 75 minute duration Will cover.
1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Trees.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
CHAPTER 11 TREES INTRODUCTION TO TREES ► A tree is a connected undirected graph with no simple circuit. ► An undirected graph is a tree if and only.
Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9 Trees.
Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Discrete Mathematics Chapter 10 Trees.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Section10.1: Introduction to Trees
Applied Discrete Mathematics Week 15: Trees
Graph Graphs and graph theory can be used to model:
Discrete Mathematicsq
Trees Chapter 11.
Introduction to Trees Section 11.1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Discrete Mathematics – CIS166
Trees L Al-zaid Math1101.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Discrete Mathematics – CIS166
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
Trees Chapter 11.
Presentation transcript:

1 Section 9.1 Introduction to Trees

2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph: no multiple edges or loops –an undirected graph is a tree if and only if there is a unique simple path between any 2 of its vertices

3 Example 1 The graph at left is a tree; it is connected, and contains no simple circuits The graph at right is not a tree because it is not connected

4 Forest A forest is a graph containing no simple circuits, not necessarily connected Each connected component of a forest is a tree For example, the second graph on the previous slide is a forest consisting of the following trees:

5 Rooted tree A rooted tree is the directed graph that results from choosing a root vertex in a tree and directed each edge away from root –The parent of vertex x is the vertex y such that there is a directed edge from y to x –If y is the parent of x, then x is a child of y –Vertices with the same parents are siblings

6 More rooted tree terminology Ancestors: all vertices in the path from root to a particular vertex; root is the ancestor of all vertices Descendants: all vertices that share an ancestor Leaf: vertex with no children Internal vertex: non-leaf vertex; root is always internal, unless it’s the only vertex in the tree

7 Example 2 The tree at left can be converted to a rooted tree by choosing any vertex as root; two examples are shown below

8 M-ary tree A rooted tree in which every internal vertex has at most m children is called an m-ary tree –A full m-ary tree is an m-ary tree in which every internal vertex has exactly m children –If m = 2, we call it a binary tree

9 Example 3 The tree at left is a full 5-ary tree The tree at right is not a full m-ary tree; m can’t be 2, since some vertices have 3 children. If m is 3, the tree isn’t full.

10 Ordered rooted tree A rooted tree in which the children of each internal vertex are ordered is an ordered rooted tree –in an ordered binary tree, we refer to the first child as the left child, and the second child as the right child –the trees rooted at a vertex’s left and right child are the left and right subtrees of that vertex

11 Trees as Models Chemistry: graphs can represent molecules, with atoms as the vertices, and bonds between them as the edges Business: trees are often used to represent chain of command within organizations Computer Science: File systems are typically organized into directories containing files; the entire file system is represented as a tree with a root directory containing subdirectories, each of which may be a subtree

12 Properties of Trees A tree with n vertices has n-1 edges A full m-ary tree with n vertices has: –v = (n-1)/m internal vertices and –e = [n(m-1) + 1]/m leaves A full m-ary tree with v internal vertices has: –n = mv + 1 vertices and –e = v(m - 1) + 1 leaves A full m-ary tree with e leaves has –n = (me - 1) / (m - 1) vertices and –v = (e - 1) / (m - 1) internal vertices

13 Example 4: using tree properties to solve problems Suppose somebody starts a chain letter, asking each recipient to forward the message to four other people Some people send it on, others do not How many people have seen the message, including the original sender, if: –no one receives it more than once –the letter ends when 100 people have read it but didn’t forward it How many people did forward the message?

14 Example 4 solution The chain letter can be represented as a 4- ary tree, with internal vertices representing people who forwarded the message, and leaves representing people who didn’t So we know that the number of leaves e = 100

15 Example 4 solution Using the formula from 3 slides back, the number of people who saw the letter = the number of vertices n = (me - 1) / (m - 1) or (4 * ) / (4 - 1) = 133 The number of internal vertices represents the number of people who forwarded the message; since we know there are 100 leaves out of 133 vertices, there are 33 internal vertices

16 More tree properties Level of a vertex: length of the unique path from root to that vertex - the level of root is 0 Height of a rooted tree is the maximum of levels of all vertices - in other words, the length of the longest path from root to any vertex A rooted m-ary tree of height h is balanced if all leaves are at levels h or h-1

17 Example 5 The tree at left is a balanced binary tree; its height is 3 and all leaves are at levels 2 and 3 The tree at right is an unbalanced binary tree; its height is 3 and there are leaves at levels 1, 2 and 3

18 More tree properties There are at most m h leaves in any m-ary tree of height h If an m-ary tree of height h has e leaves, then h If the m-ary tree is full and balanced, then h =

19 Section 9.1 Introduction to Trees