The articles explain how to compute different “visible” node sets from a binary tree using level-order traversal (BFS). For the top view, nodes are selected based on horizontal distance (HD) from the root: the root has HD = 0, left child HD = HD − 1, and right child HD = HD + 1. BFS processes nodes level by level, so the first node encountered for each HD is the topmost visible node. As a result, the algorithm stores only the first node value per HD (commonly using a map keyed by HD) and then outputs values in left-to-right HD order.
For the left view, BFS processes the tree one level at a time; for each level, the first node dequeued (i == 0) is the visible one from the left. For the right view, the same BFS approach is used, but the visible node is the last node at each level (i == size − 1). Both left and right view solutions run in O(N) time with O(N) space due to the queue. The top view approach runs in O(N log N) when using an ordered map to maintain HD ordering.