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.

Slides:



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

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.
Graphs III (Trees, MSTs) (Chp 11.5, 11.6)
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
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:
Spanning Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Spanning Trees. 2 Spanning trees Suppose you have a connected undirected graph Connected: every node is reachable from every other node Undirected: edges.
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.
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.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Minimum Spanning Tree Algorithms. What is A Spanning Tree? u v b a c d e f Given a connected, undirected graph G=(V,E), a spanning tree of that graph.
Minimum Spanning Tree in Graph - Week Problem: Laying Telephone Wire Central office.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Graph Dr. Bernard Chen Ph.D. University of Central Arkansas.
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
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
Spanning Trees Introduction to Spanning Trees AQR MRS. BANKS Original Source: Prof. Roger Crawfis from Ohio State University.
Spanning Trees Introduction to Spanning Trees AQR MRS. BANKS Original Source: Prof. Roger Crawfis from Ohio State University.
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.
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.
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.
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)
1 Minimum Spanning Trees (some material adapted from slides by Peter Lee, Ananda Guna, Bettina Speckmann)
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.
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.
Discrete Mathematics Chapter 5 Trees.
Minimum- Spanning Trees
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
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.
Week 11 - Friday.  What did we talk about last time?  Paths and circuits  Matrix representation of graphs.
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)
Section10.1: Introduction to Trees
Applied Discrete Mathematics Week 15: Trees
Minimum Spanning Trees
Graph Graphs and graph theory can be used to model:
Chapter 5 : Trees.
Minimum Spanning Tree Chapter 13.6.
Discrete Mathematicsq
12. Graphs and Trees 2 Summary
CISC 235: Topic 10 Graph Algorithms.
Advanced Algorithms Analysis and Design
Short paths and spanning trees
Minimum-Cost Spanning Tree
Minimum Spanning Tree.
Minimum Spanning Trees
Minimum Spanning Tree.
CSE 373 Data Structures and Algorithms
Spanning Trees.
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
Minimum Spanning Tree.
Minimum spanning trees
Minimum Spanning Trees (MSTs)
Minimum-Cost Spanning Tree
Presentation transcript:

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 and not connected.

Internal and Terminal vertices Let T be a tree. If T has only one or two vertices, then each is called a terminal vertex. If T has at least three vertices, then a vertex of degree 1 in T is called a terminal vertex (or a leaf ), and a vertex of degree greater than 1 in T is called an internal vertex (or a branch vertex).

Rooted Tree A rooted tree is a tree in which there is one vertex that is distinguished from the others and is called the root. The level of a vertex is the number of edges along the unique path between it and the root. The height of a rooted tree is the maximum level of any vertex of the tree. Given the root or any internal vertex v of a rooted tree, The children of v are all those vertices that are adjacent to v and are one level farther away from the root than v. If w is a child of v, then v is called the parent of w, and Two distinct vertices that are both children of the same parent are called siblings. Given two distinct vertices v and w, if v lies on the unique path between w and the root, then v is an ancestor of w and w is a descendant of v. u vw root Level 0 Level 1 Level 2 Level 3 Level 4 v is a child of u. u is the parent of v. v and w are siblings. Vertices in the enclosed region are descendants of u, u is an ancestor of each.

Binary Tree A binary tree is a rooted tree in which every parent has at most two children. Each child in a binary tree is designated either a left child or a right child (but not both), Every parent has at most one left child and one right child. A full binary tree is a binary tree in which each parent has exactly two children. Given any parent v in a binary tree T, if v has a left child, then the left sub tree of v is the binary tree whose root is the left child of v, whose vertices consist of the left child of v and all its descendants, and whose edges consist of all those edges of T that connect the vertices of the left sub tree. The right sub tree of v is defined analogously. uw vx Root v is the left child of u. x is the right child of w. Left sub tree of w Right sub tree of w.

Spanning Trees A spanning tree for a graph G is a subgraph of G that contains every vertex of G and is a tree. Every connected graph has a spanning tree. Any two spanning trees for a graph have the same number of edges. Find all spanning trees for the graph G pictured below.

Minimum Spanning Trees A minimum spanning tree for a connected weighted graph is a spanning tree that has the least possible total weight compared to all other spanning trees for the graph.

Minimum Spanning Trees - Applications Network design. – telephone, electrical, hydraulic, TV cable, computer, road. You want to lease phone lines to connect different offices Phone company charges different amounts of money to connect different pairs of cities. You want a set of lines that connects all your offices with a minimum total cost.

Algorithms for finding minimum spanning Trees In 1956 and 1957 Joseph B. Kruskal and Robert C. Prim each described much more efficient algorithms to construct minimum spanning trees. Even for large graphs, both algorithms can be implemented so as to take relatively short computing times.

Kruskal’s Algorithm-Main Idea In Kruskal’s algorithm, the edges of a connected weighted graph are examined one by one in order of increasing weight. At each stage the edge being examined is added to what will become the minimum spanning tree, provided that this addition does not create a circuit.

Kruskal’s Algorithm-Steps The steps are: The forest is constructed - with each node in a separate tree. The edges are placed in a priority queue. Until we've added n-1 edges, 1. Extract the cheapest edge from the queue, 2.If it forms a cycle, reject it, 3.Else add it to the forest. Adding it to the forest will join two trees together. Every step will have joined two trees in the forest together, so that at the end, there will only be one tree in T.

Kruskal’s Algorithm-Working

Prim’s Algorithm- Working

d ab c e

d ab c e

d ab c e

d ab c e

d ab c e

d ab c e

d ab c e

d ab c e This is the minimum spanning Tree with weight 7. The algorithm terminates as all the vertices are marked in the table and we have four edges which is one less than the number of vertices.