dsa2 min read
Add One Row to Tree
Insert a new row of nodes at a given depth in a binary tree using BFS to reach the target depth level.
Read →
1575 articles
Insert a new row of nodes at a given depth in a binary tree using BFS to reach the target depth level.
Sum all nodes at the deepest level of a binary tree using BFS to process level by level.
Determine if two nodes are cousins (same depth, different parents) using BFS to track depth and parent.
Count nodes in complete binary tree in O(log^2 n) by comparing left vs right subtree heights recursively.
Insert a value into a BST by traversing left/right based on comparisons until reaching a null position.