C++ Pre-Order, In-Order, Post-Order Traversal of Binary Search Trees

Pre-Order, In-Order, Post-Order traversal of Binary Search Trees (BST)

This article explains the depth first search (DFS) traversal methods for binary search search trees.
• Pre-Order, In-Order and Post-Order are depth first search traversal methods for binary search trees.
• Starting at the root of binary tree the order in which the nodes are visited define these traversal types.
• Basically there are 3 main steps. (1) Visit the current node, (2) Traverse the left node and (3) Traverse the right nodes.

From Wikipedia,

• To traverse a non-empty binary search tree in pre-order, perform the following operations recursively at each node, starting with the root node:
1. Visit the root.
2. Traverse the left sub-tree.
3. Traverse the right sub-tree.
• To traverse a non-empty binary search tree in in-order (symmetric), perform the following operations recursively at each node:
1. Traverse the left sub-tree.
2. Visit the root.
3. Traverse the right sub-tree.
• To traverse a non-empty binary search tree in post-order, perform the following operations recursively at each node:
1. Traverse the left sub-tree.
2. Traverse the right sub-tree.
3. Visit the root.