Please help me , i am not getting the answer


please tell my mistakes in comments so that i can remember next time.

u have misunderstood the problem. u need to form balanced bst but u r forming normal bst thats why u r getting different order.
image
follow this->

  • Get the Middle of the array and make it root.
  • Recursively do same for left half and right half.
    • 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 1.

image

1 Like