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
First line of input contains the number of test cases T. For each test case, there will be only a single line of input which is a string representing the tree as described below:
The values in the string are in the order of level order traversal of the tree where, numbers denotes node values, and a character “N” denotes NULL child.
For the above tree, the string will be: 1 2 3 N N 4 6 N 5 N N 7 N
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. The printing is done by the driver code.