Complete the code to initialize the queue with the root node for level-order traversal.
queue = [[1]]The level-order traversal starts by adding the root node to the queue.
Complete the code to remove the first node from the queue during traversal.
current_node = queue.[1]In level-order traversal, nodes are removed from the front of the queue using pop(0).
Fix the error in the code to add the left child to the queue if it exists.
if current_node.[1] is not None: queue.append(current_node.left)
The left child of a node is accessed by the attribute 'left'.
Fill both blanks to add the right child to the queue if it exists.
if current_node.[1] is not None: queue.[2](current_node.right)
The right child is accessed by 'right' and added to the queue using 'append'.
Fill all three blanks to create a dictionary comprehension that maps each node to its level in the tree during BFS.
levels = { [1]: [2] for [3] in nodes }This comprehension creates a dictionary where each node maps to its level. 'node' is the variable, 'level' is the value, and 'node.value' would be incorrect here.