pre-order traversal
Visiting a node first, then its left subtree, then its right subtree.
In more detail
Because each parent comes before its children, pre-order output can rebuild the same binary search tree when re-inserted in order. It suits copying or serializing a tree.
Related terms
- tree traversal — Visiting every node of a tree exactly once in a systematic order.
- post-order traversal — Visiting a node's left subtree, then its right subtree, and the node itself last.
Taught in
- Binary Trees And Their Traversals — Algorithms & Data Structures for Working Engineers