A Introduction to Computing II Lecture 13: Trees

Slides:



Advertisements
Similar presentations
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Advertisements

What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Trees Chapter 11.
Chapter 9 Graphs.
2012: J Paul GibsonT&MSP: Mathematical FoundationsMAT7003/L2-GraphsAndTrees.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson,
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
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:
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
CS 206 Introduction to Computer Science II 10 / 31 / 2008 Happy Halloween!!! Instructor: Michael Eckmann.
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.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
16-Graphs Graphs Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
CISC220 Fall 2009 James Atlas Nov 13: Graphs, Line Intersections.
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
Lecture 11 CSE 331 Sep 25, Homeworks Please hand in your HW 2 now HW 3 and graded HW 1 at the end of class.
Important Problem Types and Fundamental Data Structures
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture 13 Graphs. Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the.
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.
Lecture 17 Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
Discrete Structures Trees (Ch. 11)
Introduction to Graph Theory
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
COSC 2007 Data Structures II Chapter 14 Graphs I.
Discrete Mathematics Chapter 5 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.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
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.
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.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
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)
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Main algorithm with recursion: We’ll have a function DFS that initializes, and then calls DFS-Visit, which is a recursive function and does the depth first.
Graph Graphs and graph theory can be used to model:
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
CS 367 – Introduction to Data Structures
CSE 2331/5331 Topic 9: Basic Graph Alg.
Introduction to Trees Section 11.1.
Depth-First Search.
Chapter 1.
Graph Algorithms Using Depth First Search
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Planarity Testing.
Elementary graph algorithms Chapter 22
Chapter 9: Graphs Basic Concepts
Trees (Part 1, Theoretical)
Trees L Al-zaid Math1101.
Richard Anderson Autumn 2016 Lecture 5
Graphs Examples on some basic graph concepts and definitions All graphics are taken from the LEDA demos: basic_graph_algorithms, gw_shortest_paths, graphwin.
Theorem 5.13: For vT‘, l’(v)= min{l(v), l(vk)+w(vk, v)}
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Mathematics for Computer Science MIT 6.042J/18.062J
Bridges and Articulation Points
Elementary graph algorithms Chapter 22
Important Problem Types and Fundamental Data Structures
Richard Anderson Lecture 5 Graph Theory
Algorithms CSCI 235, Spring 2019 Lecture 33 Graphs II
Non-Linear data structures
Chapter 9: Graphs Basic Concepts
Concepts of Computation
Heaps Chapter 6 Section 6.9.
Presentation transcript:

308-203A Introduction to Computing II Lecture 13: Trees Fall Session 2000

Trees as graphs We’ve already seen particular examples of trees, aka: Binary search trees Call trees of recursive functions (e.g. Merge-sort) Heaps More generally trees are a special kind of graphs…

Definition Definition: A Forest is an undirected, acyclic graph

Definition Definition: A Free Tree is a connected, undirected, acyclic graph Note: the connected components of a forest are (free) trees

Is this really what we’ve seen before as trees? We have not (yet) made any distinction of “parent” or “child” vertices. Topologically, the structure has the same important properties, as we will see presently...

Defining Characteristics The following statements are equivalent: 1. G = (V, E) is a (free) tree 2. Any two vertices v0 and v1 in V are connected by a unique, simple path 3. G is singly-connected (removing any edge disconnects the graph) More on next slide…

Defining Characteristics The following statements are equivalent: 4. G is connected and |E| = |V| -1 5. G is acyclic and |E| = |V| -1 6. G is acyclic but the addition of any edge will create a cycle More on previous slide…

Proof We prove the following sequence of the above facts: 1  2  3  4  5  6  1 This means any one of these six assertions proves all the others.

Any questions?

Rooted Trees For a tree G = (V, E), pick any vertex v in V and call it the “root.” All v’s neighbors are considered “children” of v. In this way, we can define a parent-child relationship for neighboring nodes in G.

Rooted Trees You can think of “rooting” a tree in terms of the following recursive pseudocode: RootTree(Vertex v) { for u  neighbors(v) parent(v) = u if v  parent(u), child(u) = child(u)  v RootTree(u) }

Example Consider “b” the root of this (otherwise free) tree root c b h g b e f

Example Consider “b” the root of this (otherwise free) tree c b h a a g b e f

Example Consider “b” the root of this (otherwise free) tree c b h a a g b c g e f

Example Consider “b” the root of this (otherwise free) tree c b h a a g b c g e f e f h Isomorphic tree with parent/child relationships Original tree

K-ary trees Definition: A rooted tree for which every vertex has at most k children is called a k-ary tree. Definition: In particular, a k-ary tree in which every vertex has at most 2 children is called binary tree. Definition: A k-ary tree in which every vertex has exactly k children is called a complete k-ary tree.

Facts For a complete k-ary tree with of depth d: There are k i nodes at depth i There are n = (k d - 1)/(k-1) nodes Conversely, for a complete k-ary tree of n nodes, the depth is d = logk [ n (k-1) + 1] = O( log n)

Any questions?