Walk this tree in zigzag order: one level at a time, alternating left to right and right to left.
A binary search tree with 7 nodes. Walking it in zigzag order, which visits one level at a time, alternating left to right and right to left.
50 is the root, and level order starts at the top.
Visiting 50, number 1 of 7. The order so far is 50.
70 is next on its level, which this time is read right to left.
Visiting 70, number 2 of 7. The order so far is 50, 70.
30 is next on its level, which this time is read right to left.
Visiting 30, number 3 of 7. The order so far is 50, 70, 30.
20 is next on its level, which this time is read left to right.
Visiting 20, number 4 of 7. The order so far is 50, 70, 30, 20.
40 is next on its level, which this time is read left to right.
Visiting 40, number 5 of 7. The order so far is 50, 70, 30, 20, 40.
60 is next on its level, which this time is read left to right.
Visiting 60, number 6 of 7. The order so far is 50, 70, 30, 20, 40, 60.
80 is next on its level, which this time is read left to right. That is the last one.
Visiting 80, number 7 of 7. The order so far is 50, 70, 30, 20, 40, 60, 80.
The zigzag walk is 50, 70, 30, 20, 40, 60, 80.
The zigzag traversal visited 50, 70, 30, 20, 40, 60, 80.