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