Why isnt this working

#include<bits/stdc++.h>
using namespace std;

class node{
public:
int data;
nodeleft;
node
right;

node(int d){
	data=d;
	left=NULL;
	right=NULL;
}

};

node* buildBST(int a,int n,int s,int e){
if(s>e){
return NULL ;
}
int mid=(s+e)/2;
node
root= new node(a[mid]);
root->left=buildBST(a,n-1,s,mid-1);
root->right=buildBST(a,n-1,mid+1,e);
return root;
}

void printBST(node*root){
if(root==NULL){
return ;
}
cout<data<<" ";
printBST(root->left);
printBST(root->right);
}

int main(){
int t;
cin>>t;
while(t–){

int n;
cin>>n;
int a[n]={0};
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a,a+n);
node*root=buildBST(a,n,0,n-1);
printBST(root);
cout<<endl;

}

}

@gabbar_2229, you should not sort the array as input is provided to you in sorted way which can be asending or desending and if input is provided to u in desending manner than your code provides wrong output

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.