Concept Flow - Top View of Binary Tree
Start at root node
Assign horizontal distance = 0
Use queue for level order traversal
For each node dequeued:
Check if horizontal distance seen before?
Add node to top view
Ignore node
Enqueue left child with hd-1
Enqueue right child with hd+1
Repeat until queue empty
Sort nodes by horizontal distance
Print top view nodes
Traverse the tree level by level, track horizontal distances, and record the first node at each horizontal distance to get the top view.