| | | | | |

Tree Traversals - 1

Definition: A traversal is process for "visiting" all of the vertices in a tree

  • Often, but not always, defined recursively
  • Each kind of traversal corresponds to an iterator type
  • Iterators are implemented non-recursively

Preorder Traversal:

  • Visit vertex, then visit child vertices (recursive definition)
  • Depth-first search, beginning at root; visit vertex on arrival
  • Implementation may be recursive, stack-based, or nested loop
  • Animation

| | Top of Page | 10. Trees 1: Theory, Models, Generic Heap Algorithms, Priority Queues - 5 of 22