Jump to content

Pre-order traversal

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Poor Yorick (talk | contribs) at 08:40, 8 April 2003. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In Computer science, Pre-order traversal is used in Data structures, and specifically, Trees and Binary Trees.

Steps to Preorder Traversal

Given a non-empty tree,

  1. Process the root
  2. Process the nodes in the left subtree with a recursive call
  3. Process the nodes in the right subtree with a recursive call

Given a binary tree PY:

File:TreePY.gif

The order would go A,B,D,E,G,C,F

Compare: Inorder traversal, Post-order traversal