Data Structures Trees Question:
What is pre-order and in-order tree traversal?
Answer:
A non-empty binary tree is traversed in 3 types, namely pre-order, in-order and post-order in a recursive fashion.
Pre-order:
Pre-order process is as follows:
- Visit the root node
- Traverse the left sub tree
- Traverse the right sub tree
In-Order:
In order process is as follows:
- Traverse the left sub tree
- Visit the root node
- Traverse the right sub tree
Pre-order:
Pre-order process is as follows:
- Visit the root node
- Traverse the left sub tree
- Traverse the right sub tree
In-Order:
In order process is as follows:
- Traverse the left sub tree
- Visit the root node
- Traverse the right sub tree
Previous Question | Next Question |
How to find the depth of a binary tree? | Explain B+ tree? Explain its uses? |