Binary Tree Level-order Traversal Using Breadth-First Search
Level-order traversal of a binary tree visits nodes from left to right across each depth level before moving deeper. This process aligns with breadth-first search (BFS) in graph theory, applied specifically to tree structures.
A queue is used as the supporting data structure because its first-in-first-out behavior naturally matches the need to ...
Posted on Tue, 04 Aug 2026 16:33:33 +0000 by rcmehta_14
Zigzag Level Order Traversal of Binary Tree
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its zigzag level order traversal as:
[
[3],
[20,9],
[15,7]
]
Appr ...
Posted on Mon, 27 Jul 2026 16:05:55 +0000 by Hypnos
Binary Tree Traversal Techniques: Recursive and Iterative Approaches
Recusrive Traversal Patterns
Recursive implmeentations follow the core principle of processing the root node before/after children.
Preorder Trvaersal (Root-Left-Right)
class Solution {
public:
void processNode(TreeNode* current, std::vector<int>& output) {
if (!current) return;
output.push_back(current->val); ...
Posted on Mon, 25 May 2026 18:00:11 +0000 by Grizzzzzzzzzz