Week 11 - Friday.  What did we talk about last time?  Paths and circuits  Matrix representation of graphs.

Slides:



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

Trees Chapter 11.
Chapter 9 Graphs.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Graphs III (Trees, MSTs) (Chp 11.5, 11.6)
Week 12 - Monday.  What did we talk about last time?  Trees  Graphing functions.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Applied Discrete Mathematics Week 12: 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.
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.
Binary Trees Chapter 6.
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
Copyright © Cengage Learning. All rights reserved.
Week 15 - Friday.  What did we talk about last time?  Review second third of the course.
Graph Theory Topics to be covered:
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
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
Week 12 - Friday.  What did we talk about last time?  Asymptotic notation.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
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.
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Week 11 - Friday.  What did we talk about last time?  Graph isomorphism  Trees.
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.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
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)
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.
COSC 2007 Data Structures II Chapter 14 Graphs I.
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.
Unit – V Graph theory. Representation of Graphs Graph G (V, E,  ) V Set of vertices ESet of edges  Function that assigns vertices {v, w} to each edge.
Graph Theory and Applications
Introduction to Trees IT12112 Lecture 05 Introduction Tree is one of the most important non-linear data structures in computing. It allows us to implement.
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.
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.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
Discrete Mathematics Chapter 10 Trees. Outline 10.1 Introduction to Trees 10.2 Applications of Trees 10.3 Tree Traversal 10.4 Spanning Trees 10.5 Minimal.
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.
Trees.
Applied Discrete Mathematics Week 15: Trees
Week 12 - Friday CS322.
Chapter 5 : Trees.
Discrete Mathematicsq
Graph theory Definitions Trees, cycles, directed graphs.
12. Graphs and Trees 2 Summary
Advanced Algorithms Analysis and Design
And the Final Subject is…
Presentation transcript:

Week 11 - Friday

 What did we talk about last time?  Paths and circuits  Matrix representation of graphs

 You are the despotic ruler of an ancient empire  Tomorrow is the 25th anniversary of your reign  You have 1,000 bottles of wine you were planning to open for the celebration  Your Grand Vizier uncovered a plot to murder you:  10 years ago, a rebel worked in the vineyard that makes your wine  He poisoned one of the 1,000 bottles you are going to serve tonight and has been waiting for revenge  The rebel died an accidental death, and his papers revealed his plan, but not which bottle was poisoned  The poison exhibits no symptoms until death  Death occurs within ten to twenty hours after consuming even the tiniest amount of poison  You have over a thousand slaves at your disposal and just under 24 hours to determine which single bottle is poisoned  You have a few hundred prisoners, sentenced to death  Can you use just the prisoners and risk no slaves?  If so, what's the smallest number of prisoners you can risk and still be sure to find the bottle?

 There are many, many different ways to represent a graph  If you get tired of drawing pictures or listing ordered pairs, a matrix is not a bad way  To represent a graph as an adjacency matrix, make an n x n matrix, where n is the number of vertices  Let the nonnegative integer at a ij give the number of edges from vertex i to vertex j  A simple graph will always have either 1 or 0 for every location

 We can find the number of walks of length k that connect two vertices in a graph by raising the adjacency matrix of the graph to the k th power  Raising a matrix to the zero th power means you can only get from a vertex to itself (identity matrix)  Raising a matrix to the first power means that the number of paths of length one from one vertex to another is exactly the number of edges between them  The result holds for all k, but we aren't going to prove it

 A property is called an isomorphism invariant if its truth or falsehood does not change when considering a different (but isomorphic) graph  10 common isomorphism invariants: 1. Has n vertices 2. Has m edges 3. Has a vertex of degree k 4. Has m vertices of degree k 5. Has a circuit of length k 6. Has a simple circuit of length k 7. Has m simple circuits of length k 8. Is connected 9. Has an Euler circuit 10. Has a Hamiltonian circuit

 If any of the invariants have different values for two different graphs, those graphs are not isomorphic  Use the 10 invariants given to show that the following pair of graphs is not isomorphic

Student Lecture

 A tree is a graph that is circuit-free and connected  Examples: A graph made up of disconnected trees is called a forest

 Trees have almost unlimited applications  You should all be familiar with the concept of a decision tree from programming Score on Part I Score on Part II Math 120 Math 110 Math 100 < 8 = 8, 9, 10 > 10  10 > 6  6 6

 A grammar for a formal language (such as we will discuss next week or the week after) is made up of rules that allow non- terminals to be turned into other non-terminals or terminals  For example: 1.  2.  | 3.  4.  a | an | the 5.  funky 6.  DJ | beat 7.  plays | spins  Make a parse tree corresponding to the sentence, "The DJ plays a funky beat"

 Any tree with more than one vertex has at least one vertex of degree 1  If a vertex in a tree has degree 1 it is called a terminal vertex (or leaf)  All vertices of degree greater than 1 in a tree are called internal vertices (or branch vertices)

 For any positive integer n, a tree with n vertices must have n – 1 edges  Prove this by mathematical induction  Hint: Any tree with 2 or more nodes has a vertex of degree 1. What happens when you remove that vertex?

 In a rooted tree, one vertex is distinguished and 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  The children of any vertex v in a rooted tree are all those nodes that are adjacent to v and one level further away from the root than v  Two distinct vertices that are children of the same parent are called siblings  If w is a child of v, then v is the parent of w  If v is on the unique path from w to the root, then v is an ancestor of w and w is a descendant of v

 Consider the following tree, rooted at 0  What is the level of 5?  What is the level of 0?  What is the height of this tree?  What are the children of 3?  What is the parent of 2?  What are the siblings of 8?  What are the descendants of 3?

 A binary tree is a rooted tree in which every parent has at most two children  Each child is designated either the left child or the right child  In a full binary tree, each parent has exactly two children  Given a parent v in a binary tree, the left subtree of v is the binary tree whose root is the left child of v  Ditto for right subtree

 As we all know from data structures, a binary tree can be used to make a data structure that is efficient for insertions, deletions, and searches  But, it doesn't stop there!  We can represent binary arithmetic with a binary tree  Make a binary tree for the expression ((a – b)∙c) + (d/e)  The root of each subtree is an operator  Each subtree is either a single operand or another expression

 If k is a positive integer and T is a full binary tree with k internal vertices, then T has a total 2k + 1 vertices and has k + 1 terminal vertices  Prove it!  Hint: Induction isn't needed. We just need to relate the number of non-terminal nodes to the number of terminal nodes

 If T is a full binary tree with height h, then it has 2 h+1 – 1 vertices  Prove it using induction!

 If T is a binary tree with t terminal vertices and height h, then t  2 h  Prove it using strong induction on the height of the tree  Hint: Consider cases where the root of the tree has 1 child and 2 children separately

 Consider the following graph that shows all the routes an airline has between cities Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 What if we want to remove routes (to save money)?  How can we keep all cities connected? Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 Does this tree have the smallest number of routes?  Why? Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 A spanning tree for a graph G is a subgraph of G that contains every vertex of G and is a tree  Some properties:  Every connected graph has a spanning tree ▪ Why?  Any two spanning trees for a graph have the same number of edges ▪ Why?

 In computer science, we often talk about weighted graphs when tackling practical applications  A weighted graph is a graph for which each edge has a real number weight  The sum of the weights of all the edges is the total weight of the graph  Notation: If e is an edge in graph G, then w(e) is the weight of e and w(G) is the total weight of G  A minimum spanning tree (MST) is a spanning tree of lowest possible total weight

 Here is the graph from before, with labeled weights Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 Kruskal's algorithm gives an easy to follow technique for finding an MST on a weighted, connected graph  Informally, go through the edges, adding the smallest one, unless it forms a circuit  Algorithm:  Input: Graph G with n vertices  Create a subgraph T with all the vertices of G (but no edges)  Let E be the set of all edges in G  Set m = 0  While m < n – 1 ▪ Find an edge e in E of least weight ▪ Delete e from E ▪ If adding e to T doesn't make a circuit ▪ Add e to T ▪ Set m = m + 1  Output: T

 Run Kruskal's algorithm on the city graph: Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 Output: Minneapolis Milwaukee Chicago St. Louis Detroit Cincinnati Louisville Nashville

 Prim's algorithm gives another way to find an MST  Informally, start at a vertex and add the next closest node not already in the MST  Algorithm:  Input: Graph G with n vertices  Let subgraph T contain a single vertex v from G  Let V be the set of all vertices in G except for v  For i from 1 to n – 1 ▪ Find an edge e in G such that: ▪ e connects T to one of the vertices in V ▪ e has the lowest weight of all such edges ▪ Let w be the endpoint of e in V ▪ Add e and w to T ▪ Delete w from V  Output: T

 Apply Kruskal's algorithm to the graph below  Now, apply Prim's algorithm to the graph below  Is there any other MST we could make?

 Graphing functions  Asymptotic notation

 Start reading Chapter 11  Finish Assignment 8  Due tonight by midnight  Internship opportunity:  CLAIR Global in Lititz, PA  Enterprise Resource Planning software developer  Looking for candidates with MS Visual Studio and MS SQL Server Management Studio