1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Trees.

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

Chapter 9 Graphs.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
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 Jake’s Pizza Shop Owner Jake Manager Chef Brad Carol Waitress Waiter Cook Helper Joyce Chris Max Len.
EC-211 DATA STRUCTURES LECTURE Tree Data Structure Introduction –The Data Organizations Presented Earlier are Linear in That Items are One After.
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:
Discrete Mathematics – CIS166
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
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.
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.
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
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 and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
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.
CS Data Structures Chapter 15 Trees Mehmet H Gunes
Section 10.1 Introduction to Trees These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 6 th ed., by Kenneth.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
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 Dr. B. Prabhakaran Application Examples Useful for locating items in a list Used in Huffman coding algorithm Study games like.
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.
Discrete Structures Trees (Ch. 11)
Chap 8 Trees Def 1: A tree is a connected,undirected, graph with no simple circuits. Ex1. Theorem1: An undirected graph is a tree if and only if there.
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.
1 Nell Dale Chapter 8 Binary Search Trees Modified from the slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus C++ Plus Data.
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.
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.
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.
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.
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 Nell Dale Chapter 8 Binary Search Trees Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus C++ Plus Data Structures.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Discrete Mathematics Chapter 10 Trees.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Section10.1: Introduction to Trees
Trees.
Applied Discrete Mathematics Week 15: Trees
Graph Graphs and graph theory can be used to model:
Discrete Mathematicsq
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
12. Graphs and Trees 2 Summary
Binary Trees "A tree may grow a thousand feet tall, but its leaves will return to its roots." -Chinese Proverb.
Introduction to Trees Section 11.1.
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.
Discrete Mathematics – CIS166
Trees L Al-zaid Math1101.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Discrete Mathematics – CIS166
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
A Binary Tree is a tree in which each node has at most 2 children
Presentation transcript:

1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Trees

2 Definition 1. A tree is a connected undirected graph with no simple circuits. Theorem 1. An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices. Tree

3 Which graphs are trees? a) b) c)

4 Specify a vertex as root c) Then, direct each edge away from the root. ROOT

5 Specify a root. a) ROOT Then, direct each edge away from the root.

6 Specify a root. a) ROOT Then, direct each edge away from the root.

7 Specify a root. a) ROOT Then, direct each edge away from the root. A directed graph called a rooted tree results.

8 a) ROOT Then, direct each edge away from the root. What if a different root is chosen?

9 a) ROOT Then, direct each edge away from the root. What if a different root is chosen?

10 a) ROOT Then, direct each edge away from the root. What if a different root is chosen?

11 a) ROOT Then, direct each edge away from the root. What if a different root is chosen? A different rooted tree results.

12 Jake’s Pizza Shop Tree Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len

13 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len A Tree Has a Root TREE ROOT

14 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len Leaf nodes have no children LEAF NODES

15 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len A Tree Has Levels LEVEL 0

16 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len Level One LEVEL 1

17 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len Level Two LEVEL 2

18 SIBLINGS Sibling nodes have same parent Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len

19 SIBLINGS Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len Sibling nodes have same parent

20 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len A Subtree LEFT SUBTREE OF ROOT ROOT

21 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len Another Subtree RIGHT SUBTREE OF ROOT ROOT

22 A vertex that has children is called an internal vertex. The subtree at vertex v is the subgraph of the tree consisting of vertex v and its descendants and all edges incident to those descendants. Internal Vertex

23 Owner Jake Manager Brad Chef Carol WaitressWaiter Cook Helper Joyce Chris Max Len How many internal vertices?

24 Definition 2 ’. A rooted tree is called a binary tree if every internal vertex has no more than 2 children. The tree is called a full binary tree if every internal vertex has exactly 2 children. Binary Tree

25 Definition 2 ’’. An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered. In an ordered binary tree, the two possible children of a vertex are called the left child and the right child, if they exist. Ordered Binary Tree

26 Theorem 2. A tree with N vertices has N-1 edges. Theorem 5. There are at most 2 H leaves in a binary tree of height H. Corallary. If a binary tree with L leaves is full and balanced, then its height is H =  log 2 L . Tree Properties

27 An Ordered Binary Tree Hal Lou Ken Joe Ted Sue Ed Max

28 l The parent of a non-root vertex is the unique vertex u with a directed edge from u to v. Parent

29 Hal Lou Ken Joe Ted Sue Ed Max What is the parent of Ed?

30 l A vertex is called a leaf if it has no children. Leaf

31 Hal Lou Ken Joe Ted Sue Ed Max How many leaves?

32 l The ancestors of a non-root vertex are all the vertices in the path from root to this vertex. Ancestors

33 Hal Lou Ken Joe Ted Sue Ed Max How many ancestors of Ken?

34 l The descendants of vertex v are all the vertices that have v as an ancestor. Descendants

35 Hal Lou Ken Joe Ted Sue Ed Max How many descendants of Hal?

36 l The level of vertex v in a rooted tree is the length of the unique path from the root to v. Level

37 What is the level of Ted? Hal Lou Ken Joe Ted Sue Ed Max

38 l The height of a rooted tree is the maximum of the levels of its vertices. Height

39 What is the height? Hal Lou Ken Joe Ted Sue Ed Max

40 l A rooted binary tree of height H is called balanced if all its leaves are at levels H or H-1. Balanced

41 Is this binary tree balanced? Hal Lou Ken Joe Ted Sue Ed Max