Discrete Mathematics Chapter 5 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.
SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
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:
CS 171: Introduction to Computer Science II
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
Binary Trees Terminology A graph G = is a collection of nodes and edges. An edge (v 1,v 2 ) is a pair of vertices that are directly connected. A path,
Chapter 4: Trees General Tree Concepts Binary Trees Lydia Sinapova, Simpson College Mark Allen Weiss: Data Structures and Algorithm Analysis in Java.
Binary Tree Terminology Linear versus hierarchical data Tree – connected graph with no cycles Child Parent Descendant Sibling Ancestor Leaf vs. internal.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Trees.
CHAPTER 12 Trees. 2 Tree Definition A tree is a non-linear structure, consisting of nodes and links Links: The links are represented by ordered pairs.
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.
Data Structures – Binary Tree
Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Lecture 81 Data Structures, Algorithms & Complexity Tree Algorithms GRIFFITH COLLEGE DUBLIN.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
1 Trees 2 Binary trees Section Binary Trees Definition: A binary tree is a rooted tree in which no vertex has more than two children –Left and.
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.
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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
Binary Trees 2 Overview Trees. Terminology. Traversal of Binary Trees. Expression Trees. Binary Search Trees.
Data Structures and Algorithms Lecture (BinaryTrees) Instructor: Quratulain.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Trees Dale Roberts, Lecturer
Tree Data Structures.
Computer Science: A Structured Programming Approach Using C Trees Trees are used extensively in computer science to represent algebraic formulas;
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
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.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Recursion and Trees Dale Roberts, Lecturer
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Chapter 4: Trees Part I: General Tree Concepts Mark Allen Weiss: Data Structures and Algorithm Analysis in Java.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
Trees By P.Naga Srinivasu M.tech,(MBA). Basic Tree Concepts A tree consists of finite set of elements, called nodes, and a finite set of directed lines.
1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Trees.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
DATA STRUCTURE BS(IT)3rd. Tree An Introduction By Yasir Mustafa Roll No. BS(IT) Bahauddin Zakariya University, Multan.
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.
Hello Everyone!!! 1. Tree And Graphs 2 Features of Trees  Tree Nodes Each node have 0 or more children A node have must one parent  Binary tree Tree.
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.
Question 4 Tutorial 8. Part A Insert 20, 10, 15, 5,7, 30, 25, 18, 37, 12 and 40 in sequence into an empty binary tree
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)
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Trees Chapter 15.
CSCE 210 Data Structures and Algorithms
Week 6 - Wednesday CS221.
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
12. Graphs and Trees 2 Summary
Tree.
Introduction to Trees Section 11.1.
Section 8.1 Trees.
CS223 Advanced Data Structures and Algorithms
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Chapter 20: Binary Trees.
Binary Trees.
General Tree Concepts Binary Trees
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
A Binary Tree is a tree in which each node has at most 2 children
Presentation transcript:

Discrete Mathematics Chapter 5 Trees

7.1 Introduction Tree A tree is a connected undirected graph that contains no circuits. Recall: A circuit is a path of length >=1 that begins and ends a the same vertex.

Free tree A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

Rooted tree A rooted tree is a tree where one of its vertices is designated the root

Level of a vertex and tree height Let T be a rooted tree: The level l(v) of a vertex v is the length of the simple path from v to the root of the tree The height h of a rooted tree T is the maximum of all level numbers of its vertices: h = max { l(v) } v  V(T) Example: the tree on the right has height 3

7.2 Terminology

Root Leaf Siblings Parent of node n Child of node n The only node in the tree with no parent Leaf A node with no children Siblings Nodes with a common parent Parent of node n The node directly above node n in the tree Child of node n A node directly below node n in the tree

Internal and terminal vertices An internal vertex is a vertex that has at least one child A terminal vertex is a vertex that has no children The tree in the example has 4 internal vertices and 4 terminal vertices

7.5 Binary trees A binary tree is a tree where each vertex has zero, one or two children

Full binary tree A full binary tree is a binary tree in which each vertex has two or no children.

Binary search trees Data are associated to each vertex Order data alphabetically, so that for each vertex v, data to the left of v are less than data in v and data to the right of v are greater than data in v

Example: Number of nodes=7 Number of comparison=4 Element exists

Example: Number of nodes=7 Number of comparison=3 Element exists

Example: Key=15 Number of nodes=7 Number of comparison=4 Element isn’t exists

Building trees:

Another example:

Operations on trees: Insert or add on tree.

2) Deletion.

7.6 Tree Traversals 1: Pre-order traversal NLR

7.6 Tree Traversals 1: in-order traversal LNR

More on tree traversals 3: Post-order traversal LRN