Given a binary tree, connect the nodes that are at same level.
Structure of the given Binary Tree node is like following.
Initially, all the nextRight pointers point to garbage values. Your function should set these pointers to point next right for each node.
10 10 ------> NULL
/ \ / \
3 5 => 3 ------> 5 --------> NULL
/ \ \ / \ \
4 1 2 4 --> 1 -----> 2 -------> NULL
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line contains number of edges. The second line contains relation between nodes.
For each testcase, in a new line, print the level order and inorder traversals.
You don't have to take input. Complete the function connect that takes node as parameter and connects the nodes at same level.