What's wrong with my code?

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

class BinaryTreeNode{
public:
int data;
BinaryTreeNode* left;
BinaryTreeNode* right;

BinaryTreeNode(int data){
	this->data=data;
	left=NULL;
	right=NULL;
}

};

BinaryTreeNode* BST_constructor(int* a,int si,int ei){
if(si>ei){
return NULL;
}
int mid=(si+ei)/2;
BinaryTreeNode* root=new BinaryTreeNode(a[mid]);
root->left=BST_constructor(a,si,mid-1);
root->right=BST_constructor(a,mid+1,ei);
return root;
}

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

int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
BinaryTreeNode* root=BST_constructor(a,0,n-1);
print(root);
cout<<endl;
}
return 0;
}

hi @nakshjain buddy dont sort the array its already sorted (as such there should be no issues but its failing coz of 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.