Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

Chapter 9 Graphs.
2012: J Paul GibsonT&MSP: Mathematical FoundationsMAT7003/L2-GraphsAndTrees.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson,
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Graph-02.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Review Binary Search Trees Operations on Binary Search Tree
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:
Applied Discrete Mathematics Week 12: Trees
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
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.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Binary Trees Chapter 6.
GRAPH Learning Outcomes Students should be able to:
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
Graph Theory Topics to be covered:
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.
CS Data Structures Chapter 5 Trees. Chapter 5 Trees: Outline  Introduction  Representation Of Trees  Binary Trees  Binary Tree Traversals 
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
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.
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.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Based on slides by Y. Peng University of Maryland
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.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Discrete Structures Trees (Ch. 11)
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Week 8 - Wednesday.  What did we talk about last time?  Level order traversal  BST delete  2-3 trees.
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.
CSCI 171 Presentation 9 Matrix Theory. Matrix – Rectangular array –i th row, j th column, i,j element –Square matrix, diagonal –Diagonal matrix –Equality.
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.
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.
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
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.
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.
Chapter 05 Introduction to Graph And Search Algorithms.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Week 11 - Friday.  What did we talk about last time?  Paths and circuits  Matrix representation of graphs.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
1 Lecture 5 (part 2) Graphs II (a) Circuits; (b) Representation Reading: Epp Chp 11.2, 11.3
What is a Tree? Formally, we define a tree T as a set of nodes storing elements such that the nodes have a parent-child relationship, that satisfies the.
Section10.1: Introduction to Trees
Applied Discrete Mathematics Week 15: Trees
Graph Graphs and graph theory can be used to model:
12. Graphs and Trees 2 Summary
Introduction to Trees Section 11.1.
Advanced Algorithms Analysis and Design
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
Presentation transcript:

Week 11 - Wednesday

 What did we talk about last time?  Graphs  Euler paths and tours

 One hundred ants are walking along a meter long stick  Each ant is traveling either to the left or the right with a constant speed of 1 meter per minute  When two ants meet, they bounce off each other and reverse direction  When an ant reaches an end of the stick, it falls off  Will all the ants fall off?  What is the longest amount of time that you would need to wait to guarantee that all ants have fallen off?

 An Euler circuit has to visit every edge of a graph exactly once  A Hamiltonian circuit must visit every vertex of a graph exactly once (except for the first and the last)  If a graph G has a Hamiltonian circuit, then G has a subgraph H with the following properties:  H contains every vertex of G  H is connected  H has the same number of edges as vertices  Every vertex of H has degree 2  In some cases, you can use these properties to show that a graph does not have a Hamiltonian circuit  In general, showing that a graph has or does not have a Hamiltonian circuit is NP-complete (widely believed to take exponential time)  Does the following graph have a Hamiltonian circuit? e b ac d

 As you presumably know, a matrix is a rectangular array of elements  An m x n matrix has m rows and n columns

 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

 What is the adjacency matrix for the following graph?  What about for this one? v1v1 v1v1 v3v3 v3v3 v2v2 v2v2 v3v3 v3v3 v2v2 v2v2 v1v1 v1v1

 Draw a graph corresponding to this matrix

 What's the adjacency matrix of this graph?  Note that the matrix is symmetric  In a symmetric matrix, a ij = a ji for all 1 ≤ i ≤ n and 1 ≤ j ≤ n  All undirected graphs have a symmetric matrix representation v1v1 v1v1 v4v4 v4v4 v2v2 v2v2 v3v3 v3v3

 To multiply matrices A and B, it must be the case that A is an m x k matrix and that B is a k x n matrix  Then, the i th row, j th column of the result is the dot product of the i th row of A with the j th column of B  In other words, we could compute element c ij in the result matrix C as follows:

 Multiply matrices A and B

 Matrix multiplication is associative  That is, A(BC) = (AB)C  Matrix multiplication is not commutative  AB is not always equal to BA (for one thing, BA might not even be legal if AB is)  There is an n x n identity matrix I such that, for any m x n matrix A, AI = A  I is all zeroes, except for the diagonal (where row = column) which is all ones  We can raise square matrices to powers using the following recursive definition  A 0 = I, where I is the n x n identity matrix  A k = AA k-1, for all integers k ≥ 1

 Is A symmetric?  Compute A 0  Compute A 1  Compute A 2  Compute A 3

 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 zeroth 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

 Spanning trees  Graphing functions

 Keep reading Chapter 10  Start Chapter 11  Start work on Assignment 9  Due next Friday