Complete the code to initialize the queue with the root node for level order traversal.
queue = [[1]] # Start with root node in queue
We start the traversal by putting the root node inside the queue.
Complete the code to toggle the direction for zigzag traversal after each level.
left_to_right = not [1]
We flip the boolean variable left_to_right to change direction after each level.
Fix the error in the code to append children nodes correctly during traversal.
if node.left: [1].append(node.left) if node.right: queue.append(node.right)
Children nodes must be added to the queue to be processed in next levels.
Fill both blanks to collect node values in correct order for zigzag traversal.
if left_to_right: level_values.[1](node.val) else: level_values.[2](0, node.val)
When going left to right, append values at the end. When right to left, insert at start to reverse order.
Fill all three blanks to complete the dictionary comprehension that maps node values to their depths.
depth_map = { [1]: [2] for [3] in nodes_with_depth }This comprehension creates a dictionary where keys are node values and values are their depths.
