Given below is a tree. The task is to print the Reverse Level Order Traversal of the given tree. You will be given a function reversePrint(), which accepts root of the tree as argument.
The first line of input contains T, denoting the number of testcases. Each testcase contains number of edges. The second line contains number of edges+1 data of nodes of tree separated by space.
For each testcase in new line, print the reverse level order traversal of tree separated by space.
Since this is a functional problem you don't have to worry about input, you just have to complete the function reversePrint().
1 <= T <= 30
1 <= Number of edges <= 3*103
1 <= Data of a node <= 3*103
1 2 R 1 3 L
10 20 L 10 30 R 20 40 L 20 60 R
3 2 1
40 60 20 30 10
Testcase 1: There are total 3 nodes of tree.
Reverse level order traversal of tree is: 3 2 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.