Level order, breadth first search or zig-zag traversal of a binary tree
Traverse the binary tree in breadth first search also known as level order traversal manner.
// Should print 8, 3, 10, 1, 6, 14, 4, 7, 13
Pseudo Algorithm
PSEUDO ALGORITHM (Breadth first search approach)
- Create an empty queue q
- Enqueue q the root node
- Loop while queue is not EMPTY
- temp_node = dequeue q
- print temp_node’s data
- Enqueue temp_node’s children (first left then right children) to q
---
---