Step 1: Start BFS from root (20) at horizontal distance 0
Map: {0: 20}
Queue: [(20,0)]Why: Initialize with root node at horizontal distance 0
Step 2: Pop (20,0), add left child (8,-1) and right child (22,1)
Map: {0: 20}
Queue: [(8,-1), (22,1)]Why: Add children with updated horizontal distances
Step 3: Pop (8,-1), add left child (5,-2) and right child (3,0), update map at -1
Map: {-1: 8, 0: 20}
Queue: [(22,1), (5,-2), (3,0)]Why: Update bottom view for horizontal distance -1 and add children
Step 4: Pop (22,1), add right child (25,2), update map at 1
Map: {-1: 8, 0: 20, 1: 22}
Queue: [(5,-2), (3,0), (25,2)]Why: Update bottom view for horizontal distance 1 and add child
Step 5: Pop (5,-2), no children, update map at -2
Map: {-2: 5, -1: 8, 0: 20, 1: 22}
Queue: [(3,0), (25,2)]Why: Update bottom view for horizontal distance -2
Step 6: Pop (3,0), add left child (10,-1) and right child (14,1), update map at 0
Map: {-2: 5, -1: 8, 0: 3, 1: 22}
Queue: [(25,2), (10,-1), (14,1)]Why: Update bottom view for horizontal distance 0 and add children
Step 7: Pop (25,2), no children, update map at 2
Map: {-2: 5, -1: 8, 0: 3, 1: 22, 2: 25}
Queue: [(10,-1), (14,1)]Why: Update bottom view for horizontal distance 2
Step 8: Pop (10,-1), no children, update map at -1
Map: {-2: 5, -1: 10, 0: 3, 1: 22, 2: 25}
Queue: [(14,1)]Why: Update bottom view for horizontal distance -1 with lower node
Step 9: Pop (14,1), no children, update map at 1
Map: {-2: 5, -1: 10, 0: 3, 1: 14, 2: 25}
Queue: []Why: Update bottom view for horizontal distance 1 with lower node
Result: Bottom view nodes by horizontal distance:
-2: 5 -> -1: 10 -> 0: 3 -> 1: 14 -> 2: 25