Medium Accuracy: 36.98% Submissions: 7953 Points: 4
Given a Binary Tree, write a function to populate next pointer for all nodes. The next pointer for every node should be set to point to inorder successor.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the number of edges respectively. The last line contains the edges of the tree.
Print the data for both nodes separated by "->" ( without quotes). -1 is printed if there is no successor for the node.
1<=data of the node<=10^5