# LOGO.  Trees:  In these slides: Introduction to trees Applications of trees Tree traversal 2.

## Presentation on theme: "LOGO.  Trees:  In these slides: Introduction to trees Applications of trees Tree traversal 2."— Presentation transcript:

LOGO

 Trees:  In these slides: Introduction to trees Applications of trees Tree traversal 2

LOGO 3

4 Introduction to Trees  A tree is a connected undirected graph that contains no circuits.  Theorem: There is a unique simple path between any two of its nodes.

LOGO 5 Introduction to Trees  A tree is a connected undirected graph that contains no circuits.  Theorem: There is a unique simple path between any two of its nodes.  A (not-necessarily-connected) undirected graph without simple circuits is called a forest.  You can think of it as a set of trees having disjoint sets of nodes.

LOGO 6 Introduction to Trees  A tree is a connected undirected graph that contains no circuits.  Theorem: There is a unique simple path between any two of its nodes.  A (not-necessarily-connected) undirected graph without simple circuits is called a forest.  You can think of it as a set of trees having disjoint sets of nodes.  A leaf node in a tree or forest is any pendant or isolated vertex. An internal node is any non-leaf vertex (thus it has degree ≥ ? ).

LOGO 7 Introduction to Trees  A tree is a connected undirected graph that contains no circuits.  Theorem: There is a unique simple path between any two of its nodes.  A (not-necessarily-connected) undirected graph without simple circuits is called a forest.  You can think of it as a set of trees having disjoint sets of nodes.  A leaf node in a tree or forest is any pendant or isolated vertex. An internal node is any non-leaf vertex (thus it has degree ≥ 2 ).

LOGO 8 Tree and Forest Examples  A Tree:  A Forest: Leaves in green, internal nodes in brown.

LOGO 9 Rooted Trees  A rooted tree is a tree in which one node has been designated the root.  Every edge is (implicitly or explicitly) directed away from the root.

LOGO 10 Rooted Trees  A rooted tree is a tree in which one node has been designated the root.  Every edge is (implicitly or explicitly) directed away from the root.  Concepts related to rooted trees:  Parent, child, siblings, ancestors, descendents, leaf, internal node, subtree.

LOGO 11 Rooted Tree Examples  Note that a given unrooted tree with n nodes yields n different rooted trees. root Same tree except for choice of root

LOGO 12 Rooted-Tree Terminology Exercise  Find the parent, children, siblings, ancestors, & descendants of node f. a b c d e f g h i jk l m n o p q r root

LOGO 13 n-ary trees  A rooted tree is called n-ary if every vertex has no more than n children.  It is called full if every internal (non-leaf) vertex has exactly n children.

LOGO 14 n-ary trees  A rooted tree is called n-ary if every vertex has no more than n children.  It is called full if every internal (non-leaf) vertex has exactly n children.  A 2-ary tree is called a binary tree.  These are handy for describing sequences of yes- no decisions. Example: Comparisons in binary search algorithm.

LOGO 15 Which Tree is Binary?  Theorem: A given rooted tree is a binary tree iff every node other than the root has degree ≤ ___, and the root has degree ≤ ___.

LOGO 16 Ordered Rooted Tree  This is just a rooted tree in which the children of each internal node are ordered.

LOGO 17 Ordered Rooted Tree  This is just a rooted tree in which the children of each internal node are ordered.  In ordered binary trees, we can define:  left child, right child  left subtree, right subtree

LOGO 18 Ordered Rooted Tree  This is just a rooted tree in which the children of each internal node are ordered.  In ordered binary trees, we can define:  left child, right child  left subtree, right subtree  For n-ary trees with n>2, can use terms like “leftmost”, “rightmost,” etc.

LOGO 19 Trees as Models  Can use trees to model the following:  Saturated hydrocarbons  Organizational structures  Computer file systems  In each case, would you use a rooted or a non- rooted tree?

LOGO 20 Some Tree Theorems  Any tree with n nodes has e = n−1 edges.  Proof: Consider removing leaves.

LOGO 21 Some Tree Theorems  Any tree with n nodes has e = n−1 edges.  Proof: Consider removing leaves.  A full m-ary tree with i internal nodes has n=mi+1 nodes, and =(m−1)i+1 leaves.  Proof: There are mi children of internal nodes, plus the root. And, = n−i = (m−1)i+1. □

LOGO 22 Some Tree Theorems  Any tree with n nodes has e = n−1 edges.  Proof: Consider removing leaves.  A full m-ary tree with i internal nodes has n=mi+1 nodes, and =(m−1)i+1 leaves.  Proof: There are mi children of internal nodes, plus the root. And, = n−i = (m−1)i+1. □  Thus, when m is known and the tree is full, we can compute all four of the values e, i, n, and, given any one of them.

LOGO 23 Some More Tree Theorems  Definition: The level of a node is the length of the simple path from the root to the node.  The height of a tree is maximum node level.  A rooted m-ary tree with height h is called balanced if all leaves are at levels h or h−1.

LOGO 24 Some More Tree Theorems  Definition: The level of a node is the length of the simple path from the root to the node.  The height of a tree is maximum node level.  A rooted m-ary tree with height h is called balanced if all leaves are at levels h or h−1.  Theorem: There are at most m h leaves in an m-ary tree of height h.  Corollary: An m-ary tree with leaves has height h≥  log m . If m is full and balanced then h=  log m .

LOGO 25

LOGO 26 Applications of Trees  Binary search trees  A simple data structure for sorted lists

LOGO 27 Applications of Trees  Binary search trees  A simple data structure for sorted lists  Decision trees  Minimum comparisons in sorting algorithms

LOGO 28 Applications of Trees  Binary search trees  A simple data structure for sorted lists  Decision trees  Minimum comparisons in sorting algorithms  Prefix codes  Huffman coding

LOGO 29 Applications of Trees  Binary search trees  A simple data structure for sorted lists  Decision trees  Minimum comparisons in sorting algorithms  Prefix codes  Huffman coding  Game trees

LOGO 30 Binary Search Trees  A representation for sorted sets of items.  Supports the following operations in Θ(log n) average-case time: Searching for an existing item. Inserting a new item, if not already present.  Supports printing out all items in Θ(n) time.  Note that inserting into a plain sequence a i would instead take Θ(n) worst- case time.

LOGO 31 Binary Search Tree Format  Items are stored at individual tree nodes.  We arrange for the tree to always obey this invariant:  For every item x, Every node in x’s left subtree is less than x. Every node in x’s right subtree is greater than x. 7 312 15915 02811 Example:

LOGO 32 Recursive Binary Tree Insert procedure insert(T: binary tree, x: item) v := root[T] if v = null then begin root[T] := x; return “Done” end else if v = x return “Already present” else if x v} return insert(rightSubtree[T], x)

LOGO 33 Decision Trees  A decision tree represents a decision-making process.  Each possible “decision point” or situation is represented by a node.  Each possible choice that could be made at that decision point is represented by an edge to a child node.

LOGO 34 Decision Trees  A decision tree represents a decision-making process.  Each possible “decision point” or situation is represented by a node.  Each possible choice that could be made at that decision point is represented by an edge to a child node.  In the extended decision trees used in decision analysis, we also include nodes that represent random events and their outcomes.

LOGO 35 Coin-Weighing Problem  Imagine you have 8 coins, one of which is a lighter counterfeit, and a free-beam balance.  No scale of weight markings is required for this problem!  How many weighings are needed to guarantee that the counterfeit coin will be found? ?

LOGO 36 As a Decision-Tree Problem  In each situation, we pick two disjoint and equal- size subsets of coins to put on the scale. The balance then “decides” whether to tip left, tip right, or stay balanced. A given sequence of weighings thus yields a decision tree with branching factor 3.

LOGO 37 Applying the Tree Height Theorem  The decision tree must have at least 8 leaf nodes, since there are 8 possible outcomes.  In terms of which coin is the counterfeit one.  Recall the tree-height theorem, h≥  log m .  Thus the decision tree must have height h ≥  log 3 8  =  1.893…  = 2.  Let’s see if we solve the problem with only 2 weighings…

LOGO 38 General Solution Strategy  The problem is an example of searching for 1 unique particular item, from among a list of n otherwise identical items.  Somewhat analogous to the adage of “searching for a needle in haystack.”  Armed with our balance, we can attack the problem using a divide- and-conquer strategy, like what’s done in binary search.  We want to narrow down the set of possible locations where the desired item (coin) could be found down from n to just 1, in a logarithmic fashion.  Each weighing has 3 possible outcomes.  Thus, we should use it to partition the search space into 3 pieces that are as close to equal-sized as possible.  This strategy will lead to the minimum possible worst-case number of weighings required.

LOGO 39 General Balance Strategy  On each step, put  n/3  of the n coins to be searched on each side of the scale.  If the scale tips to the left, then: The lightweight fake is in the right set of  n/3  ≈ n/3 coins.  If the scale tips to the right, then: The lightweight fake is in the left set of  n/3  ≈ n/3 coins.  If the scale stays balanced, then: The fake is in the remaining set of n − 2  n/3  ≈ n/3 coins that were not weighed!  Except if n mod 3 = 1 then we can do a little better by weighing  n/3  of the coins on each side. You can prove that this strategy always leads to a balanced 3-ary tree.

LOGO 40 Coin Balancing Decision Tree  Here’s what the tree looks like in our case: 123 vs 456 1 vs. 2 left: 123 balanced: 78 right: 456 7 vs. 8 4 vs. 5 L:1 R:2B:3 L:4 R:5B:6 L:7 R:8

LOGO 41

LOGO Universal Address Systems To totally order the vertices of on ordered rooted tree: 1.Label the root with the integer 0. 2.Label its k children (at level 1) from left to right with 1, 2, 3, …, k. 3.For each vertex v at level n with label A, label its k v children, from left to right, with A.1, A.2, A.3, …, A.k v. 42

LOGO Universal Address Systems To totally order the vertices of on ordered rooted tree: 1.Label the root with the integer 0. 2.Label its k children (at level 1) from left to right with 1, 2, 3, …, k. 3.For each vertex v at level n with label A, label its k v children, from left to right, with A.1, A.2, A.3, …, A.k v. This labeling is called the universal address system of the ordered rooted tree. 43

LOGO Traversal Algorithms  A traversal algorithm is a procedure for systematically visiting every vertex of an ordered rooted tree  An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered 45

LOGO Traversal Algorithms  A traversal algorithm is a procedure for systematically visiting every vertex of an ordered rooted tree  An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered  The three common traversals are:  Preorder traversal  Inorder traversal  Postorder traversal 46

LOGO Traversal  Let T be an ordered rooted tree with root r.  Suppose T 1, T 2, …,T n are the subtrees at r from left to right in T. r T1T1 T2T2 TnTn 47

LOGO Preorder Traversal r T1T1 T2T2 TnTn Step 1: Visit r Step 2: Visit T 1 in preorder Step 3: Visit T 2 in preorder. Step n+1: Visit T n in preorder 48

LOGO Preorder Traversal r T1T1 T2T2 TnTn Step 1: Visit r Step 2: Visit T 1 in preorder Step 3: Visit T 2 in preorder. Step n+1: Visit T n in preorder 49

LOGO Preorder Traversal r T1T1 T2T2 TnTn Step 1: Visit r Step 2: Visit T 1 in preorder Step 3: Visit T 2 in preorder. Step n+1: Visit T n in preorder 50

LOGO Preorder Traversal r T1T1 T2T2 TnTn Step 1: Visit r Step 2: Visit T 1 in preorder Step 3: Visit T 2 in preorder. Step n+1: Visit T n in preorder 51

LOGO Preorder Traversal r T1T1 T2T2 TnTn Step 1: Visit r Step 2: Visit T 1 in preorder Step 3: Visit T 2 in preorder. Step n+1: Visit T n in preorder 52

LOGO Example M A R EY P M HJ QT Tree: Visiting sequence: 53

LOGO Example AM A R EY P M HJ QT Tree: Visiting sequence: 54

LOGO Example AMJ A R EY P M HJ QT Tree: Visiting sequence: 55

LOGO Example AYMJ A R EY P M HJ QT Tree: Visiting sequence: 56

LOGO Example ARYMJ A R EY P M HJ QT Tree: Visiting sequence: 57

LOGO Example ARYMHJ A R EY P M HJ QT Tree: Visiting sequence: 58

LOGO Example ARYPMHJ A R EY P M HJ QT Tree: Visiting sequence: 59

LOGO Example ARYPMHJQ A R EY P M HJ QT Tree: Visiting sequence: 60

LOGO Example ARYPMHJQT A R EY P M HJ QT Tree: Visiting sequence: 61

LOGO Example AREYPMHJQT A R EY P M HJ QT Tree: Visiting sequence: 62

LOGO The Preorder Traversal of T In which order does a preorder traversal visit the vertices in the ordered rooted tree T shown to the left? Remember: Visit root, then visit subtrees left to right. 63

LOGO The Preorder Traversal of T 64

LOGO The Preorder Traversal of T 65

LOGO The Preorder Traversal of T 66

LOGO The Preorder Traversal of T 67

LOGO Inorder Traversal Step 1: Visit T 1 in inorder Step 2: Visit r Step 3: Visit T 2 in inorder. Step n+1: Visit T n in inorder r T1T1 T2T2 TnTn 68

LOGO Inorder Traversal Step 1: Visit T 1 in inorder Step 2: Visit r Step 3: Visit T 2 in inorder. Step n+1: Visit T n in inorder r T1T1 T2T2 TnTn 69

LOGO Inorder Traversal Step 1: Visit T 1 in inorder Step 2: Visit r Step 3: Visit T 2 in inorder. Step n+1: Visit T n in inorder r T1T1 T2T2 TnTn 70

LOGO Inorder Traversal Step 1: Visit T 1 in inorder Step 2: Visit r Step 3: Visit T 2 in inorder. Step n+1: Visit T n in inorder r T1T1 T2T2 TnTn 71

LOGO Inorder Traversal Step 1: Visit T 1 in inorder Step 2: Visit r Step 3: Visit T 2 in inorder. Step n+1: Visit T n in inorder r T1T1 T2T2 TnTn 72

LOGO Example J A R EY P M HJ QT Tree: Visiting sequence: 73

LOGO Example AJ A R EY P M HJ QT Tree: Visiting sequence: 74

LOGO Example AMJ A R EY P M HJ QT Tree: Visiting sequence: 75

LOGO Example ARMJ A R EY P M HJ QT Tree: Visiting sequence: 76

LOGO Example ARYMJ A R EY P M HJ QT Tree: Visiting sequence: 77

LOGO Example ARYPMJ A R EY P M HJ QT Tree: Visiting sequence: 78

LOGO Example ARYPMHJ A R EY P M HJ QT Tree: Visiting sequence: 79

LOGO Example ARYPMHJQ A R EY P M HJ QT Tree: Visiting sequence: 80

LOGO Example ARYPMHJQT A R EY P M HJ QT Tree: Visiting sequence: 81

LOGO Example AREYPMHJQT A R EY P M HJ QT Tree: Visiting sequence: 82

LOGO The Inorder Traversal of T In which order does an inorder traversal visit the vertices in the ordered rooted tree T shown to the left? Remember: Visit leftmost tree, visit root, visit other subtrees left to right. 83

LOGO The Inorder Traversal of T 84

LOGO The Inorder Traversal of T 85

LOGO The Inorder Traversal of T 86

LOGO The Inorder Traversal of T 87

LOGO Postorder Traversal Step 1: Visit T 1 in postorder Step 2: Visit T 2 in postorder. Step n: Visit T n in postorder Step n+1: Visit r r T1T1 T2T2 TnTn 88

LOGO Postorder Traversal Step 1: Visit T 1 in postorder Step 2: Visit T 2 in postorder. Step n: Visit T n in postorder Step n+1: Visit r r T1T1 T2T2 TnTn 89

LOGO Postorder Traversal Step 1: Visit T 1 in postorder Step 2: Visit T 2 in postorder. Step n: Visit T n in postorder Step n+1: Visit r r T1T1 T2T2 TnTn 90

LOGO Postorder Traversal Step 1: Visit T 1 in postorder Step 2: Visit T 2 in postorder. Step n: Visit T n in postorder Step n+1: Visit r r T1T1 T2T2 TnTn 91

LOGO Postorder Traversal Step 1: Visit T 1 in postorder Step 2: Visit T 2 in postorder. Step n: Visit T n in postorder Step n+1: Visit r r T1T1 T2T2 TnTn 92

LOGO Example J A R EY P M HJ QT Tree: Visiting sequence: 93

LOGO Example AJ A R EY P M HJ QT Tree: Visiting sequence: 94

LOGO Example ARJ A R EY P M HJ QT Tree: Visiting sequence: 95

LOGO Example ARPJ A R EY P M HJ QT Tree: Visiting sequence: 96

LOGO Example ARPJQ A R EY P M HJ QT Tree: Visiting sequence: 97

LOGO Example ARPJQT A R EY P M HJ QT Tree: Visiting sequence: 98

LOGO Example ARPHJQT A R EY P M HJ QT Tree: Visiting sequence: 99

LOGO Example ARYPHJQT A R EY P M HJ QT Tree: Visiting sequence: 100

LOGO Example AREYPHJQT A R EY P M HJ QT Tree: Visiting sequence: 101

LOGO Example AREYPMHJQT A R EY P M HJ QT Tree: Visiting sequence: 102

LOGO The Postorder Traversal of T In which order does a postorder traversal visit the vertices in the ordered rooted tree T shown to the left? Remember: Visit subtrees left to right, then visit root. 103

LOGO The Postorder Traversal of T 104

LOGO The Postorder Traversal of T 105

LOGO The Postorder Traversal of T 106

LOGO The Postorder Traversal of T 107

LOGO Representing Arithmetic Expressions  Complicated arithmetic expressions can be represented by an ordered rooted tree  Internal vertices represent operators  Leaves represent operands 108

LOGO Representing Arithmetic Expressions  Complicated arithmetic expressions can be represented by an ordered rooted tree  Internal vertices represent operators  Leaves represent operands  Build the tree bottom-up  Construct smaller subtrees  Incorporate the smaller subtrees as part of larger subtrees 109

LOGO Example (x+y) 2 + (x-3)/(y+2) 110

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 111

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 2  112

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 2  – x 3 113

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 2  – x 3 + y 2 114

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 2  – x 3 + y 2 / 115

LOGO Example (x+y) 2 + (x-3)/(y+2) + x y 2  – x 3 + y 2 / + 116

LOGO Evaluating Prefix Notation  In an prefix expression, a binary operator precedes its two operands  The expression is evaluated right-left  Look for the first operator from the right  Evaluate the operator with the two operands immediately to its right 117

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 118

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 119

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 120

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 121

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 122

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 123

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 124

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 125

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 + / 4 2 1 126

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 + / 4 2 1 127

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 + / 4 2 1 + 2 1 128

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 + / 4 2 1 + 2 1 129

LOGO Example + / + 2 2 2 / – 3 2 + 1 0 + / + 2 2 2 / – 3 2 1 + / + 2 2 2 / 1 1 + / + 2 2 2 1 + / 4 2 1 + 2 1 3 130

LOGO Postfix Notation (Reverse Polish) Traverse in postorder +  – + / + 2 x y x 3 y 2 131

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x +  – + / + 2 x y x 3 y 2 132

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x y +  – + / + 2 x y x 3 y 2 133

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y +  – + / + 2 x y x 3 y 2 134

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y 2 +  – + / + 2 x y x 3 y 2 135

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 +  – + / + 2 x y x 3 y 2 136

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x +  – + / + 2 x y x 3 y 2 137

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x 3 +  – + / + 2 x y x 3 y 2 138

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x – 3 +  – + / + 2 x y x 3 y 2 139

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x – 3 y +  – + / + 2 x y x 3 y 2 140

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x – 3 y 2 +  – + / + 2 x y x 3 y 2 141

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x – 3 y + 2 +  – + / + 2 x y x 3 y 2 142

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 x – 3 / y + 2 +  – + / + 2 x y x 3 y 2 143

LOGO Postfix Notation (Reverse Polish) Traverse in postorder x + y  2 + x – 3 / y + 2 +  – + / + 2 x y x 3 y 2 144

LOGO  In an postfix expression, a binary operator follows its two operands  The expression is evaluated left-right  Look for the first operator from the left  Evaluate the operator with the two operands immediately to its left Evaluating Postfix Notation 145

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 146

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 147

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 148

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 149

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 150

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 151

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 152

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 153

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 2 1 1 / + 154

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 2 1 1 / + 155

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 2 1 1 / + 2 1 + 156

LOGO Example 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 2 1 1 / + 2 1 + 157

LOGO Example 3 2 2 + 2 / 3 2 – 1 0 + / + 4 2 / 3 2 – 1 0 + / + 2 3 2 – 1 0 + / + 2 1 1 0 + / + 2 1 1 / + 2 1 + 158

LOGO 159 Spanning Trees  You will learn about the following topics in tree later in other courses:  Spanning Trees  Minimum Spanning Trees

LOGO Good Luck

Download ppt "LOGO.  Trees:  In these slides: Introduction to trees Applications of trees Tree traversal 2."

Similar presentations