Download presentation
Presentation is loading. Please wait.
Published byRosalyn Ross Modified over 9 years ago
1
Trees – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Trees Reading: Kolman, Section 7.1
2
Trees – Page 2CSCI 1900 – Discrete Structures Brain Teaser Assume you are driving with your child, and he/she is screaming for the milk out of his happy meal. You haven’t cleaned out the car in a while, so there are 9 milk bottles rolling around on the floorboards under your feet, one full, 8 half full and a bit foul. Assuming you can pick up more than one bottle at a time in each hand, using your hands as balance scales, how many “balances” will it take for you to find the full bottle.
3
Trees – Page 3CSCI 1900 – Discrete Structures Trees – Their Definition Let A be a set and let T be a relation on A. We say that T is a tree if there is a vertex v 0 with the property that there exists a unique path in T from v 0 to every other vertex in A, but no path from v 0 to v 0. -Kolman, Busby, and Ross, p. 254
4
Trees – Page 4CSCI 1900 – Discrete Structures Trees – Our Definition We need a way to describe a tree, specifically a “rooted” tree. –First, a rooted tree has a single root, v 0, which is a vertex with absolutely no edges coming into it. (in- degree of v 0 = 0) –Every other vertex, v, in the tree has exactly one path to it from v 0. (in-degree of v = 1) –There may be any number of paths coming out from any vertex. –Denoted (T,v 0 )
5
Trees – Page 5CSCI 1900 – Discrete Structures Trees – Characteristics If T is a relation that is also a tree, then T must have the following characteristics: –There are no cycles in T –V 0 is the only root of T
6
Trees – Page 6CSCI 1900 – Discrete Structures Examples of Trees Using the definitions given above, determine which of the following examples are trees and which are not.
7
Trees – Page 7CSCI 1900 – Discrete Structures Is this a tree?
8
Trees – Page 8CSCI 1900 – Discrete Structures Is this a tree?
9
Trees – Page 9CSCI 1900 – Discrete Structures Is this a tree? CSCI 2910 Client & Server Side Prog CSCI 2800 Visual Prog Adv Concepts CSCI 1100 Using Info Technology CSCI 1710 WWW Design CSCI 1510 Student in University CSCI 1800 Visual Prog I CSCI 2150 Computer Organization CSCI 2235 Intro to Unix CSCI 3220 Intro to Database CSCI 3250 Software Engineering I CSCI 3350 Software Engineering II CSCI 4217 Ethical Issues CSCI 4800 Senior Capstone Technology CSCI 4227 Advanced Database CSCI 3400 Network Fundamentals CSCI 4417 System Administration
10
Trees – Page 10CSCI 1900 – Discrete Structures Is this a tree? Microsoft’s troubleshooting wizard.
11
Trees – Page 11CSCI 1900 – Discrete Structures Is this a tree? for i = 0 to 256 for j = 0 to 16 array[i,j] = 1000*i + j next j next i
12
Trees – Page 12CSCI 1900 – Discrete Structures Is this a tree? for i = 0 to 256 for j = 0 to 16 array[i,j] = i*j next j next i
13
Trees – Page 13CSCI 1900 – Discrete Structures Definitions Levels – all of the vertices located n- edges from v 0 are said to be at level n. Level 0 Level 1 Level 2 Level 3
14
Trees – Page 14CSCI 1900 – Discrete Structures More Definitions A vertex, v, is considered the parent of all of the vertices connected to it by edges leaving v. A vertex, v, is considered the offspring of the vertex connected to the single edge entering v. A vertex, v, is considered the sibling of all vertices at the same level with the same parent.
15
Trees – Page 15CSCI 1900 – Discrete Structures More Definitions A vertex v 2 is considered a descendant of a vertex v 1 if there is a path from v 1 to v 2. The height of a tree is the number of the largest level. The vertices of a tree that have no offspring are considered leaves. If the vertices of a level of a tree can be ordered from left to right, then the tree is an ordered tree.
16
Trees – Page 16CSCI 1900 – Discrete Structures More Definitions If every vertex of a tree has at most n offspring, then the tree is considered an n-tree. If every vertex of a tree with offspring has exactly n offspring, then the tree is considered a complete n-tree. When n=2, this is called a binary tree.
17
Trees – Page 17CSCI 1900 – Discrete Structures Examples 1.If the set A = {a, b, c, d, e} represents all of the vertices for a tree T, what is the maximum height of T? What is the minimum height of T? 2.If the set A = {a, b, c, d, e} represents all of the vertices for a tree T and T is a complete binary tree, what is the maximum height of T?
18
Trees – Page 18CSCI 1900 – Discrete Structures More Examples 3.If every path from the root of a complete 4-tree has 3 levels, how many leaves does this tree have? 4.What is n for the following n-tree? for i = 0 to 256 for j = 0 to 16 array[i,j] = 1000*i + j next j next i
19
Trees – Page 19CSCI 1900 – Discrete Structures One More Example 5.Let T be a complete n-tree with 125 leaves. a.) What are the possible values of n b.) What are the possible values for the height of T.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.