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
10 8 L 8 3 L 10 12 R
3->8 8->10 10->12 12->-1
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.