you give perfect binary tree leave level parent child the binary tree follow definitionstruct Node int val Node leave Node right Node nextPopulate pointer point right node if right node pointer set nullinitially pointer set NULL Example 1input root 1234567output 1234567explanation give perfect binary tree Figure a function populate pointer point right node like Figure B the serialized output level order connect pointer signify end levelexample 2input root Output ConstraintsThe number nod tree range 0 212 11000 Nodeval 1000 FollowupYou use constant extra spacethe recursive approach fine you assume implicit stack space count extra space problem