ZZomato·DSASenior MLDSA Round

BFS: Print the Leftmost Node at Each Level of a Tree

viaGlassdoor

Problem: Given a binary tree, print the leftmost node at each level. Constraints: Standard binary tree, arbitrary depth. Approach: Perform a level-order traversal (BFS) using a queue, and for each level, record the value of the first node dequeued (or track depth per node and take the first value seen at each new depth).

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account