Download presentation

Presentation is loading. Please wait.

Published byMaximilian Small Modified about 1 year ago

1
Lecture 16: Tree Traversal

2
Introduction

3
Tree Traversals abejknopfcdglmhi PREORDER jenkopbfaclgmdhi INORDER jhopkefbclmghida POSTORDER

4
Tree Traversal Algorithms Ordered tree traversals are based on the depth-first graph traversal. The structure of all depth- first tree traversals are the same. The diffence is in when each node is evaluated. function traverse(node: X) { for (all child nodes Y) { traverse(Y) }

5
Permutation Tree for Four Elements

6
Simple Maze Solving as Tree Traversal

7
List Representation of a Binary Tree

8
Edge List Representations of a Tree

9
Dynamic Memory Representations of a Tree

10
A General Tree in Dynamic Memory

11
Data-Tag-Next

12
Example: Breadth-First Traversal

13
Breadth-First Traversal of a Tree sample Ada Code

14
Depth-First Traversal - Binary Dreet

15
Depth-First Traversal of a Tree

16
Implementing Depth-First Traversals PREORDER INORDERPOSTORDER

17
Watching the Stack

18
Summary DFT Tree Traversals Pre-order In-order Post-order Permutation Trees Simple Maze as a Tree List Representation of a Binary Tree Edge List Representation of a Tree Trees in Dynamic Memory Data-Tag-Next: a general tree node Breadth-First Traversals Usually on Permutation Trees Iterative with a Queue Depth-First Traverals Used mostly for search and sort Recursive with a Stack

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google