trees - university of illinois · properties of trees every tree t has the following properties:...

10
Trees Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois 1

Upload: others

Post on 26-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

Trees

Discrete Structures (CS 173)

Madhusudan Parthasarathy, University of Illinois 1

Page 2: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

For notes on “free” trees, see Section 5.7 of :http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/readings/MIT6_042JF10_notes.pdf

For notes on rooted trees, see textbook.

You are required to know both free trees and rooted trees in this course.

2

Page 3: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

Trees

Definition:

A graph is a tree iff it is acyclic and connected.

Acyclic: no cycles

Leaf: A vertex of degree 1

A forest is just an acyclic graph

(each connected component is a tree).

3

Page 4: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

Properties of trees

Every tree T has the following properties:• Any connected subgraph of T is a tree.

• There is a unique simple path between every pair of vertices in T.

• Adding an edge between non-adjacent nodes in T creates a graph with a cycle.

• Removing any edge disconnects the graph.

• If any tree has at least two vertices, then it has at least two leaves.

• The number of vertices in a tree is one larger than the number of vertices: |E|=|V|-1

• If an edge is removed from a tree, then it will result in two trees.

4

Page 5: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

5

Page 6: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

6

Page 7: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

7

Page 8: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

If any tree has at least two vertices, then it has at least two leaves.

Proof:Take the longest simple path in the tree (argue why there

must be one)

Then we can argue that u1 and un must be leaves.If u1 had another neighbor than u2, say v, then:Case 1: If v is one of u3,… un, then there would be a cycle.Case 2: If v is not any of u3,…un, then we would have a

longer simple path, which contradicts our assumption.

8

Page 9: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

The number of vertices in a tree is one larger than the number of vertices: |E|=|V|-1

Proof:Induction on number of vertices, using the fact that any nontrivial tree

must have a leaf.

9

Page 10: Trees - University Of Illinois · Properties of trees Every tree T has the following properties: • Any connected subgraph of T is a tree. • There is a unique simple path between

If an edge is removed from a tree, then it will result in two trees.

Why?

Useful for induction on “free” trees:

- Free trees (nontrivial) have at least one leaf.

- Removing an edge from a free tree, results in two free trees.

10