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