Download presentation

Presentation is loading. Please wait.

Published byJuliana Patrick Modified over 7 years ago

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

2
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)

3
More Tree Theorems 5.2: In a tree with more than 1 vertex, there are at least 2 vertices of degree 1. 5.3: 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)

4
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

5
Homework Section 5.1 – pages 234-236 Exercises 1 – 18, 27

6
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

7
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?

8
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

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

10
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

11
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

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

13
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?

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

15
Section 5.3 – Depth-First Search OMIT

16
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

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

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

19
Section 5.4 Homework Omit Pages 269 – 270 Exercises Pages 271-274 1 – 12, 14, 20 – 25, 33 – 38

20
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

21
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.

22
Insertion to a Binary Search Tree (p. 298)

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

24
Searching a BST (p. 300)

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

Similar presentations

© 2022 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google