How do i make a bst without sorting the array?

I know that sorting is where i am going wrong

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/331100 I have attached the code of the input method of your reference. The code in the video was for sorted arrays

I am still getting wrong pre order, could you help figure out the problem with that part? My range function seems to be working fine though.

add a new line for every test case

Thanks, that worked !

1 Like