Binary Tree BFS — Reasoning Check

Trace frozen frontiers, sparse levels, output placement, and queue occupancy.


Get every question correct to pass this checkpoint. You can review feedback, revise your answers, and submit again.

1. A BFS queue initially holds only root R, which has leaf children A and B. The inner loop uses i < len(queue), removes one front node, and appends its children. It puts R and A in the first output level. Which repair restores the level invariant?

Select one answer.

2. Root 5 has children 9 and 1. Node 9 has only right child 7; node 1 has only left child 4. Node 7 has right leaf 8, and node 4 has left leaf 6. What is the right-side view?

Select one answer.

3. Zigzag output starts left-to-right at depth 0. At depth 3, ordinary left-to-right BFS discovers [12,3,8,6,14]. What value belongs at zero-based output index 1 for that level?
4. A tree level contains integer values [-4,0,5]. Its sum is 1 and its count is 3. Which Go expression preserves the fractional average?

Select one answer.

5. Root has children A and B; A has only right child C, and B has only left child D. Every node initially has Next pointing to itself. After Connect, which description is correct?

Select one answer.

6. A perfect binary tree has level sizes 1,2,4,8,16. BFS removes a node before appending its children. What is the maximum number of unprocessed nodes simultaneously in its FIFO queue?
Join Discord