BUILD BST: preorder print

I don’t know why but its somehow showing same output for both INORDER and PREORDER printing.

hey @mverma_be19 you misunderstood the question. In it, it’s given u need to form balanced bst but you are forming normal bst that is the reason you are getting same order of your bst.
follow these steps to make balanced BST.

  • Find the Middle of the array and make it new root.
  • Now Recursively do same for left half BST and right half BST.
    • a) Get the middle of left half and make it left child of the root created in step 1.
    • b) Get the middle of right half and make it right child of the root created in step 2.

This is the way of making balanced BST

Oh right. Thankss! Marked as resolved.

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.