← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a perfect binary tree where all leaves are on the same level and every parent has exactly two children. Each node has a left, right, and next pointer. Initially all next pointers are set to NULL. Your task is to populate each next pointer so that it points to its next right node on the same level. If there is no next right node (i.e., the node is the rightmost node on that level), the next pointer should remain NULL. You may only use constant extra space (recursive approaches are allowed with implicit stack space not counted as extra space).