I am getting a wrong output. Please help me correct my code.
Build BST problem
node* build(int n){
int d;
// cin>>d;remove from here
node*root = NULL;
while(n–){
cin>>d;//take here
root = insertInBST(root,d);
}
return root;
}
otherwise takes one extra number as input
I am still getting the same output.
Hey @rahul.gupta03111999
You haven’t understood the problem
You have to make BST from sorted array by making its middle as root and then making recursive calls for left and right
after doing that u have to print preorder
- 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.
Can you tell me how can I mark it solved?
I will do that …
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.