Download presentation
Presentation is loading. Please wait.
1
Graphs & Trees
2
Graphs Nodes connected by Edges
3
Directed Graphs Directed Graph : Edges are one way
4
Trees Trees: A trunk from the roots Divides into branches
Ends in leaves
5
Tree Strucures Directed graph with: Single root node with no parent
Edge Node
6
Tree Strucures Directed graph with: Single root node (no parent)
Parent nodes point to 1+ child nodes
7
Trees… Categorizations
8
Trees… Brackets
9
Trees… HTML documents
10
Trees… Image recognition
11
Expression Tree Represents mathematical expression (15 – 1) / 7
12
Expression Tree
13
Expression Tree
14
Traversal Most operations involve complete traversal
15
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
16
Traversal BinaryOp toString: Handleing may involve recursion
Handle left child Handle self Handle right child Handleing may involve recursion
17
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
18
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
19
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
20
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
21
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
22
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
23
Traversal BinaryOp toString: Handle left child Handle self
Handle right child
24
Traversal BinaryOp toString code Puts ( ) around node’s output
25
Traversal Most operations involve complete traversal
Relative order of Left Self Right depends on job
26
Traversal Evaluate: Evaluate left Evaluate right
Do math using left & right
27
Traversal Evaluate: Evaluate left Evaluate right
Do math using left & right
28
Traversal Evaluate code
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.