Where I am making mistake?


Not giving right output.

@raj.verma5454 you are giving wrong input, try for sample input given in question its running fine

If it is running fine for sample input then how I am giving wrong input?

@raj.verma5454 i meant in the input field in the ide.

Please help , it is not accepting my code .It says wrong answer.

@raj.verma5454 check your output statement carefully I think you are missing a space.

Still it is not accepting.

hi @raj.verma5454
for the test case
6
10
21 18 2 6 14 24 12 13 3 4
5 10
10
14 17 7 18 12 5 4 6 21 24
11 17
10
16 11 15 20 2 22 4 25 17 10
16 25
10
12 18 9 23 15 13 25 11 22 16
7 15
10
15 7 3 17 12 6 8 16 19 2
12 20
7
2 3 4 5 6 7 8
4 9

The expected output is:
#Preorder : 21 18 2 6 3 4 14 12 13 24
#Nodes within range are : 6
#Preorder : 14 7 5 4 6 12 17 18 21 24
#Nodes within range are : 12 14 17
#Preorder : 16 11 2 4 10 15 20 17 22 25
#Nodes within range are : 16 17 20 22 25
#Preorder : 12 9 11 18 15 13 16 23 22 25
#Nodes within range are : 9 11 12 13 15
#Preorder : 15 7 3 2 6 12 8 17 16 19
#Nodes within range are : 12 15 16 17 19
#Preorder : 2 3 4 5 6 7 8
#Nodes within range are : 4 5 6 7 8

But your output is
#Preorder : 21 18 2 6 3 4 14 12 13 24
#Nodes within range are :
#Preorder : 14 7 5 4 6 12 17 18 21 24
#Nodes within range are : 14 17
#Preorder : 16 11 2 4 10 15 20 17 22 25
#Nodes within range are : 14 16 17 17 20 22 25
#Preorder : 12 9 11 18 15 13 16 23 22 25
#Nodes within range are : 9 11 12 14 16 17 17 20 22 25
#Preorder : 15 7 3 2 6 12 8 17 16 19
#Nodes within range are : 9 11 12 14 15 16 16 17 17 17 19 20 22 25
#Preorder : 2 3 4 5 6 7 8
#Nodes within range are : 9 11 12 14 15 16 16 17 17 17 19 20 22 25

Note that I removed the space after # to prevent markup formatting.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Sorry but i still have a doubt. https://www.geeksforgeeks.org/print-bst-keys-in-the-given-range/ . I found this in which they re calling for left subtree if root is greater than k1 , and I was calling into right subtree . But after updating the code I still got wrong answer. Please help me out.