Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Introduction to Trees Chapter 6 Objectives
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 Section 9.1 Introduction to Trees. 2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph:
Discrete Mathematics – CIS166
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
Chapter 4: Trees General Tree Concepts Binary Trees Lydia Sinapova, Simpson College Mark Allen Weiss: Data Structures and Algorithm Analysis in Java.
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.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Data Structures Using C++ 2E Chapter 11 Binary Trees and B-Trees.
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary 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.
Copyright © Cengage Learning. All rights reserved.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
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
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.
Multiway Trees. Trees with possibly more than two branches at each node are know as Multiway trees. 1. Orchards, Trees, and Binary Trees 2. Lexicographic.
1 Section 1.4 Graphs and Trees A graph is set of objects called vertices or nodes where some pairs of objects may be connected by edges. (A directed graph.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
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.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
Lecture 8 Tree.
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.
TREES. What is a tree ? An Abstract Data Type which emulates a tree structure with a set of linked nodes The nodes within a tree are organized in a hierarchical.
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.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Discrete Mathematics Chapter 5 Trees.
1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Trees.
M180: Data Structures & Algorithms in Java Trees & Binary Trees Arab Open University 1.
Trees Dr. Yasir Ali. A graph is called a tree if, and only if, it is circuit-free and connected. A graph is called a forest if, and only if, it is circuit-free.
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.
Graphs and Trees Mathematical Structures for Computer Science Chapter 5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraphs and Trees.
Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9 Trees.
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
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
Applied Discrete Mathematics Week 15: Trees
Data Structure and Algorithms
Trees Chapter 11.
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
12. Graphs and Trees 2 Summary
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.
Trees L Al-zaid Math1101.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Trees.
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
General Tree Concepts Binary Trees
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Introduction to Trees Chapter 6 Objectives
Presentation transcript:

Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES

Copyright © Cengage Learning. All rights reserved. Rooted Trees SECTION 10.6

3 Rooted Trees An outdoor tree is rooted and so is the kind of family tree that shows all the descendants of one particular person. The terminology and notation of rooted trees blends the language of botanical trees and that of family trees. In mathematics, a rooted tree is a tree in which one vertex has been distinguished from the others and is designated the root. Given any other vertex v in the tree, there is a unique path from the root to v. (After all, if there were two distinct paths, a circuit could be constructed.)

4 Rooted Trees The number of edges in such a path is called the level of v, and the height of the tree is the length of the longest such path. It is traditional in drawing rooted trees to place the root at the top (as is done in family trees) and show the branches descending from it.

5 Rooted Trees These terms are illustrated in Figure Figure A Rooted Tree

6 Example 1 – Rooted Trees Consider the tree with root v 0 shown on the right. a. What is the level of v 5 ? b. What is the level of v 0 ? c. What is the height of this rooted tree? d. What are the children of v 3 ? e. What is the parent of v 2 ? f. What are the siblings of v 8 ? g. What are the descendants of v 3 ?

7 Example 1 – Solution a. 2 b. 0 c. 3 d. v 5 and v 6 e. v 0 f. v 7 and v 9 g. v 5, v 6, v 10

8 Rooted Trees Note that in the tree with root v 0 shown below, v 1 has level 1 and is the child of v 0, and both v 0 and v 1 are terminal vertices.

9 Binary Trees

10 Binary Trees When every vertex in a rooted tree has at most two children and each child is designated either the (unique) left child or the (unique) right child, the result is a binary tree.

11 Binary Trees These terms are illustrated in Figure Figure A Binary Tree

12 Example 2 – Representation of Algebraic Expressions Binary trees are used in many ways in computer science. One use is to represent algebraic expressions with arbitrary nesting of balanced parentheses. For instance, the following (labeled) binary tree represents the expression a/b: The operator is at the root and acts on the left and right children of the root in left-right order.

13 Example 2 – Representation of Algebraic Expressions More generally, the binary tree shown below represents the expression a/(c + d). In such a representation, the internal vertices are arithmetic operators, the terminal vertices are variables, and the operator at each vertex acts on its left and right subtrees in left-right order. Draw a binary tree to represent the expression ((a – b)  c) + (d/e). cont’d

14 Example 2 – Solution The binary tree to represent the expression ((a – b)  c) + (d/e), is as follows:

15 Binary Trees An interesting theorem about binary trees says that if you know the number of internal vertices of a full binary tree, then you can calculate both the total number of vertices and the number of terminal vertices, and conversely. More specifically, a full binary tree with k internal vertices has a total of 2k + 1 vertices of which k + 1 are terminal vertices.

16 Example 3 – Determining Whether a Certain Full Binary Tree Exists Is there a full binary tree that has 10 internal vertices and 13 terminal vertices? Solution: No. By Theorem , a full binary tree with 10 internal vertices has = 11 terminal vertices, not 13.

17 Binary Trees Another interesting theorem about binary trees specifies the maximum number of terminal vertices of a binary tree of a given height. Specifically, the maximum number of terminal vertices of a binary tree of height h is 2 h. Another way to say this is that a binary tree with t terminal vertices has height of at least log 2 t.

18 Example 4 – Determining Whether a Certain Binary Tree Exists Is there a binary tree that has height 5 and 38 terminal vertices? Solution: No. By Theorem , any binary tree T with height 5 has at most 2 5 = 32 terminal vertices, so such a tree cannot have 38 terminal vertices.