My preorder function is not working
@S19LPPP0192 hey this tree question is pretty simple was you can see the input data is sorted then you have to use application of binary search type algorithm . you have to make a recursive function in which you have to make mid as root and the input values lesser than mid value send to left side and larger value go to right hand side and return root. and pass this root to print function and you’re done.
I have made some change , if you could tell me the mistake I am making now
you can check code on previous ide onlu
@S19LPPP0192 hey kshitij there is basically four error in you program there is no need of new Node function your node class work for you. at line no 54 give node* root =new node(arr[mid])
In main function do node * root =Null
root = BuildTree ( arr , 0 , n-1 ) ;
In buildTree function you have to deference the array so In function header do int * arr ,int s, int e
and give endline for t no of test cases.