CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.

Slides:



Advertisements
Similar presentations
Chapter 11 Trees Graphs III (Trees, MSTs) Reading: Epp Chp 11.5, 11.6.
Advertisements

CSE 211 Discrete Mathematics
Trees Chapter 11.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
10.4 Spanning Trees. Def Def: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G See handout.
SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Graphs and Trees This handout: Trees Minimum Spanning Tree Problem.
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.
Graph Theory TreesAlgorithms. Graphs: Basic Definitions 4 n Let n be the number of nodes (stations) and e be the number of edges (links). n A graph is.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen 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.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
ساختمانهای گسسته دانشگاه صنعتی شاهرود – اردیبهشت 1392.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
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.
Foundations of Discrete Mathematics
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.
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.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
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.
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)
Introduction to Graph Theory
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.
Chapter 7. Trees Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University : Office : A309
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.
Trees 2: Section 4.2 and 4.3 Binary trees. Binary Trees Definition: A binary tree is a rooted tree in which no vertex has more than two children
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.
Discrete Mathematics Chapter 5 Trees.
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.
Lecture 17: Trees and Networks I Discrete Mathematical Structures: Theory and Applications.
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.
1 Trees General Trees  Nonrecursive definition: a tree consists of a set of nodes and a set of directed edges that connect pairs of nodes.
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.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
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.
1 Trees. 2 Trees Trees. Binary Trees Tree Traversal.
Section10.1: Introduction to Trees
TREES From root to leaf. Trees  A tree is a non-linear collection  The elements are in a hierarchical arrangement  The elements are not accessible.
Applied Discrete Mathematics Week 15: Trees
Chapter 5 : Trees.
Discrete Mathematicsq
Binary Search Tree (BST)
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.
Section 8.1 Trees.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
Chapter 20: Binary Trees.
Presentation transcript:

CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY

Basic Tree Tree: Connected graph with no cycles Theorem 5.1: Let U & V be vertices in a tree. Then there is exactly one simple path between U & V. Since connected, there exists at least one path If 2, then there must be a cycle (discussion pg. 231)

More Tree Theorems 5.2: In a tree with more than 1 vertex, there are at least 2 vertices of degree : A tree with n vertices has exactly n-1 edges. (Proof by induction – p. 232) 5.4a: If an edge is removed from a tree, the resulting graph is not connected (so not a tree) 5.4b: If an edge is added to a tree, the result is a cycle (so not a tree)

Theorem 5.5: Following statements are equivalent for a graph T a)T is a tree b)T is connected & V = E+1 c)T has 0 cycles & V = E+1 d)There is exactly 1 simple path between any 2 vertices e)T is connected & removal of any edge results in graph that is not connected f)T has no cycles & addition of edge between 2 non-adjacent vertices results in a cycle

Homework Section 5.1 – pages Exercises 1 – 18, 27

Example 5.2 – page 229 Build telephone network among a group towns using fewest lines possible; connections do not have to be direct, just connected Consider 5 towns Fully connected Tree See also Example 5.6 – p. 238 – Oil Pipeline

Spanning Tree Spanning tree of a graph G is a tree (connected graph with no cycles) containing all vertices of G May not be unique Note: A tree is a spanning tree. How? Remove 1 edge from each cycle. How do you find the cycles?

Breadth First Search Algorithm Using from previous chapter Edges connecting vertex to its predecessor forms a tree Can start at any vertex Produces Shortest Paths Tree

Theorem 5.6 A graph is connected iff it has a spanning tree.

Minimal & Maximal Spanning Trees Applies to Weighted Graphs Minimal Spanning Tree No other spanning tree of the graph has smaller weight May be multiple with same weight Figure 5.15 – pg. 242

Minimal Spanning Tree - Prim’s Algorithm Select any vertex, V1 Select smallest edge incident on V1 Now, some V2 is also included in selection Select smallest edge with 1 end a selected vertex & other end not selected vertex Repeat until all vertices are included

Prim’s Algorithm Complexity O(n 3 ) – n = number vertices Maximal Spanning Tree?? How can we do this?

Kruskal’s Minimal Spanning Tree Alg. (p. 252) Start with all vertices in separate sets Select smallest edge; the 2 vertex endpoints have been selected; Union the sets containing the 2 vertices Select smallest edge for which 2 endpoints are NOT in same set Repeat until all vertices are in one set How is this different from Prim’s?

Homework Section 5.2 – Pages 248 – 253 Exercises 1 – 43 (except 12, 13, 36, 37)

Section 5.3 – Depth-First Search OMIT

5.4 Rooted Trees Example: Family Tree Rooted Tree: a directed graph T such that 1.If ignore direction of edges, graph is a tree 2.There exists unique vertex R with in-degree 0, in-degree of all other V is 1 (R is called the Root) Usually draw with Root at top & other edges going down

Theorem 5.9 In a rooted tree: 1.V = E No Directed Cycles 3.Unique simple directed path from root to all other Vertices

Tree Terminology (page 268) Parent Child Ancestor Descendant Terminal Vertex – Leaf Internal Vertex

Section 5.4 Homework Omit Pages 269 – 270 Exercises Pages – 12, 14, 20 – 25, 33 – 38

5.5 Binary Trees & Traversals A rooted tree in which each vertex has at most 2 children, denoted left child & right child Left subtree of V: subtree rooted by left child of V Right subtree

5.6 Binary Search Tree (BST) (p.296) Consider – each vertex has a value. BST: For every vertex, all vertices in left subtree have greater value that root and all vertices in right subtree have values less than root.

Insertion to a Binary Search Tree (p. 298)

BST Traversals Inorder Traversal (p.282) Preorder Traversal (p. 277) Postorder Traversal (p. 281)

Searching a BST (p. 300)

Homework – 5.5 & : pages 284+ Exercises 7 – 30, 55 – : pages 302+ Exercises 48 – 73, demonstrate 74 with 2 different BST’s