Given two BST, you need to print the elements of both BSTs in sorted form.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains three lines. The first line of each test case contain's an integer N and M denoting the size of the two BST's. Then In the next two line are space separated values of the two BST's.
For each testcase, in a new line, print the elements of both BSTs in sorted form.
This is a function problem, you don't have to take any input. Just complete the function merge() that nodes of both BSTs as parameters.
1 <= T <= 100
1 <= N,M <= 100
1 33 4
6 7 1
1 1 4 6 7 33
1 2 6 9
Testcase1: The BSTs look like
The sorted elements of above BSTs are 1 1 4 6 7 33
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.