Given a perfect binary tree, populate each next pointer to point to the next right node. If there is no next right node, the next pointer should be set to NULL.
Since the tree is perfect, use constant-space level-order using existing next pointers. Process each level by linking children of connected nodes.
- Iterate level by level using leftmost node of each level.
- For each node at current level: node.left.next = node.right; if node.next: node.right.next = node.next.left.
- Advance leftmost to leftmost.left (go to next level).
- Time Complexity: O(N)
- Space Complexity: O(1)