https://ide.geeksforgeeks.org/fax6VyGGxY----the output of the sample test cases given in code is correct. But after the submission test case are not passing, what is the error in the code. I think logic is correct, but the submission is showing wrong output
Print BST keys in the given order problem
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.
but can’t i just sort the array after taking input and then perform the operation on the array?
https://ide.geeksforgeeks.org/10y7u1WUpD--- And i have tried your approach also but upon submission it’s showing wrong Answer even now. But sample input is passing perfectly fine like it was in previous code
https://ide.codingblocks.com/s/289326 corrected code.
Errors:
- Add syso at the end of every tree.print.
- For every test case create a new object of tree.
- Some errors in the printRange method.
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.