Lecture 17 Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.

Slides:



Advertisements
Similar presentations
Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Advertisements

Trees Chapter 11.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Introduction to Trees Chapter 6 Objectives
Data Structures: A Pseudocode Approach with C 1 Chapter 6 Objectives Upon completion you will be able to: Understand and use basic tree terminology and.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
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:
Section 3.1 Properties of Trees Sarah Graham. Tree Talk: Vocabulary oTree: a tree is a special type of graph that contains designated vertex called a.
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.
1 Graph Introduction Definitions. 2 Definitions I zDirected Graph (or Di-Graph) is an ordered pair G=(V,E) such that yV is a finite, non-empty set (of.
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
Important Problem Types and Fundamental Data Structures
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.
Trees. Introduction to Trees Trees are very common in computer science They come in different forms They are used as data representation in many applications.
Lecture 18 Tree Traversal CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
CS261 Data Structures Trees Introduction and Applications.
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.
Introduction to Trees. When at a node in a singly linked list, there is no choice as to which node can be visited next: Motivation when here we can only.
Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Foundations of Discrete Mathematics
7.1 and 7.2: Spanning Trees. A network is a graph that is connected –The network must be a sub-graph of the original graph (its edges must come from the.
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.
Binary Trees. Binary Tree Finite (possibly empty) collection of elements A nonempty binary tree has a root element The remaining elements (if any) are.
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.
Lecture 8 Tree.
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.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
Computer Science: A Structured Programming Approach Using C Graphs A graph is a collection of nodes, called vertices, and a collection of segments,
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.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
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.
1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus 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.
Trees – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Trees Reading: Kolman, Section 7.1.
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.
Graphs Upon completion you will be able to:
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.
Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9 Trees.
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Section10.1: Introduction to Trees
Graph Graphs and graph theory can be used to model:
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
Introduction to Trees Section 11.1.
Lecture 18. Basics and types of Trees
CS223 Advanced Data Structures and Algorithms
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Graphs Chapter 11 Objectives Upon completion you will be able to:
A Introduction to Computing II Lecture 13: Trees
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
7.1 Trees.
Heaps Chapter 6 Section 6.9.
Presentation transcript:

Lecture 17 Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine

CSCI 1900 Lecture Lecture Introduction Reading –Rosen Sections 11.1, 11.2 Review Graphs Trees Rooted Trees Specialized Trees

CSCI 1900 Lecture Review of Directed Graphs A Digraph, G=(V, A), consists of a finite set V of objects called vertices, and a finite set A of objects called arcs between the vertices Arcs have a direction Example: V={1, 2, 3} A= { (1, 2), (3, 2) } 1 2 3

CSCI 1900 Lecture Graphs A graph, G=(V, E), consists of a finite set V of objects called vertices, and a finite set E of objects called edges Edges have no direction Example: V={1,2,3} E= { (1,2), (2,3) } 1 2 3

CSCI 1900 Lecture Connected Graph A graph is connected if there is a path (sequence of edges) between any two pairs of vertices Connected Disconnected

CSCI 1900 Lecture Cycle C3C3 C4C4 If you can start at a node and move along edges and come back to the same node the graph has a cycle

CSCI 1900 Lecture Acyclic Graphs A disconnected acyclic graph Not an acyclic graph A graph is acyclic if it has no cycles

CSCI 1900 Lecture Trees 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. 271 Or A tree is a connected acyclic graph

CSCI 1900 Lecture Rooted Trees In computer science, we work primarily with rooted trees A rooted tree is a directed graph –Which has one vertex, v 0, called the root, with no arcs coming into it In-degree of v 0 = 0 –Any other vertex, v i, in the tree has exactly one path to it from v 0 In-degree of v i = 1 –There may be any number of paths from any vertex

CSCI 1900 Lecture Examples of Trees From this point forward, we will follow the computer science conventions –Tree means rooted tree –Edge means directed edge Using the definitions given, determine which of the following examples are trees and which are not

CSCI 1900 Lecture Is this a tree?

CSCI 1900 Lecture Is this a tree?

CSCI 1900 Lecture 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

CSCI 1900 Lecture Definitions Level – 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

CSCI 1900 Lecture 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 child 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

CSCI 1900 Lecture More Definitions A vertex v j is considered a descendant of a vertex v i if there is a path from v i to v j The height of a tree is the number of the largest level The vertices of a tree that have no children are called leaves

CSCI 1900 Lecture Tree Example Level 0 Level 1 Level 2 v2v2 v1v1 v5v5 v3v3 v4v4 v0v0 v6v6 v7v7 v8v8 v 0 is the parent of v 1, v 2, v 3, and v 4 v 1, v 2, v 3, and v 4 are children of v 0 v 1, v 2, v 3, and v 4 are siblings v 5, v 6, v 2, v 7, v 8, and v 4 are leaves (no children) Height of the tree is 2

CSCI 1900 Lecture More Definitions If every vertex of a tree has at most n children, 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, the tree is a binary tree

CSCI 1900 Lecture Examples 1.If the set A = {a, b, c, d, e} represents all of the vertices for a tree T, what is the maximum possible height of T? What is the minimum possible 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?

CSCI 1900 Lecture Examples (cont) 3.If the height of a complete 4-tree is 3, how many leaves does this tree have?

CSCI 1900 Lecture Key Concepts Summary Review Graphs Trees Rooted Trees Specialized Trees Reading for next time –Kolman Section 7.2, 7.3