MediumVery High Frequency25 min
Tree BFS (Level Order)
Use a queue to traverse level by level — solve right-side view, zigzag, and more.
Tree BFS (level-order) uses a queue to process nodes level by level. Pattern: capture queue.size() before inner loop to separate levels.
Tree BFS (Level-Order)
Level-Order BFS
Right Side View
O(n)Each node visited once. Queue holds at most one full level = O(w) space.Step-by-step1 / 8
Treelevel links
1. 1
Start with queue=[1]
Capture size=1. This level has only the root.
More in Trees
Binary Tree Fundamentals
Tree terminology, traversal orders (in/pre/post/level), and recursive thinking.
Tree DFS (Depth-First Search)
Recursive and iterative DFS for path sums, diameter, max depth, and subtree problems.
Binary Search Tree
BST properties, insertion, deletion, validation, and in-order traversal patterns.