BuildBST code doubt

codelink :https://ide.codingblocks.com/s/182963
I am unable to understand where I am having invalid pointers as I am getting garbage value in output please correct it

Hey just a small mistake

for(int i = 0; i < n; i++){
cin>>a[i];
}
node *root = NULL;
root = buildBst(0, n-1, a, root);
printPreOrder(root);

u did not close the for loop before calling the function

1 Like

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.