Skip to main content

Tree View - Top View

Learn Tree View - Top View (Trees, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Top View - What's Visible Looking Down Assign each node a HORIZONTAL DISTANCE (HD) from the root: root = 0, left child = parent's HD - 1, right child = parent's HD + 1. The top view shows the FIRST node encountered at each distinct horizontal distance during a level-order (BFS) scan - "first" matters because BFS processes shallower nodes before deeper ones at the same HD.

More lessons in Trees