Connect All Siblings of a Binary Tree
Try to solve the Connect All Siblings of a Binary Tree problem.
We'll cover the following
Statement
Given the root of a next
, connect all nodes from left to right. Do so in such a way that the next
pointer of each node points to its immediate right sibling except for the rightmost node, which points to the first node of the next level.
The next
pointer of the last node of the binary tree (i.e., the rightmost node of the last level) should be set to NULL.
Constraints:
- The number of nodes in the tree is in the range .
-
Node.data
Examples
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy