Recall & Review
beginner
What is Zigzag Level Order Traversal in a binary tree?
It is a way to visit nodes level by level, but alternating the direction of traversal at each level. For example, left to right on one level, then right to left on the next.
Click to reveal answer
intermediate
Why do we use two stacks or a deque in Zigzag Level Order Traversal?
To keep track of nodes in the current level and the next level while controlling the order of traversal direction (left to right or right to left) easily.
Click to reveal answer
intermediate
In Zigzag Level Order Traversal, what determines the order of adding child nodes to the next level?
The current traversal direction. If going left to right, add left child first then right child. If right to left, add right child first then left child.
Click to reveal answer
beginner
What is the time complexity of Zigzag Level Order Traversal?
O(n), where n is the number of nodes in the tree, because each node is visited exactly once.
Click to reveal answer
beginner
How does Zigzag Level Order Traversal differ from normal Level Order Traversal?
Normal level order visits nodes left to right at every level. Zigzag alternates direction each level, switching between left to right and right to left.
Click to reveal answer
What data structure is commonly used to implement Zigzag Level Order Traversal?
✗ Incorrect
Deque or two stacks help alternate the traversal direction easily by controlling the order nodes are processed.
In Zigzag traversal, if the current level is traversed left to right, how are child nodes added for the next level?
✗ Incorrect
When traversing left to right, add left child first then right child to maintain correct order for next level.
What is the output of Zigzag Level Order Traversal for a tree with root 1, left child 2, right child 3?
✗ Incorrect
First level left to right: [1], second level right to left: [3, 2].
What is the space complexity of Zigzag Level Order Traversal?
✗ Incorrect
Space complexity is O(n) because we store nodes of each level in data structures like stacks or deque.
Which of these is NOT a characteristic of Zigzag Level Order Traversal?
✗ Incorrect
Zigzag traversal does NOT always go left to right; it alternates directions.
Explain how Zigzag Level Order Traversal works step-by-step on a binary tree.
Think about how you would walk through the tree like a zigzag path.
You got /4 concepts.
Describe the difference between normal Level Order Traversal and Zigzag Level Order Traversal.
Focus on the direction of visiting nodes at each level.
You got /4 concepts.