Pre-order traversal
Appearance
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,
- Process the root
- Process the nodes in the left subtree with a recursive call
- Process the nodes in the right subtree with a recursive call
Given a binary tree PY:
The order would go A,B,D,E,G,C,F
Compare: Inorder traversal, Post-order traversal