Wrong Answer in print nodes in given range

My code seems to be correct, I am unable to detect any error. Yet it is printing a wrong answer. Could you please guide me as to where I have made the mistake.

According to me, the problem seems to be in the Pre-Order traversal, but that code seems to be alright to me.

Kindly look through and suggest changes if need be.

Regards,
Ajay Bhat.

@ajay_bhat
The array given in the input is not the preorder traversal of the BST to be formed. It is just a random unsorted array and you need to create a BST from the given unsorted array.

https://ide.codingblocks.com/s/231469 I have attached the code of the input method of your reference. The code in the video was for sorted arrays

Yes, thank you very much, I shall do the necessary changes and see.

I did the necessary changes as suggested by you. The test case seems to be passing alright, but while submitting it still shows Wrong Answer. Kindly assist.

Sorry to bother, I realized my mistake. Thanks a lot for your suggestion. It helped me clear the test case. Regards,

1 Like

@ajay_bhat,
please mark the doubt as resolved