Getting segmentation fault in build bst

this is the code i have written but getting segmentation fault:

#include
using namespace std;

class Node{

public:
int data;
Node * left;
Node * right;

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

};
void buildBST(Node * root , int arr[],int index,int n){
if(root==NULL){
Node * newNode = new Node(arr[index]);
index++;
}
if(index==n)
return ;
if(arr[index]data)
buildBST(root->left,arr,index,n);
if(arr[index]>root->data)
buildBST(root->right,arr,index,n);

}
void print(Node * 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 ele[n];
for(int i=0;i<n;i++){
cin>>ele[i];
}
Node * root=NULL;
buildBST(root,ele,0,n);
print(root);

}
return 0;

}

hi @gunvirmittal_9f1753c05330d09c send the code on ide.codingblocks.com
here its not readable

hi! i have tried sending via ide …but not able to succeed…

please try by saving in any online ide and send me the link @gunvirmittal_9f1753c05330d09c save it there and send the code try once more, login,write,save(ctrl+s), send the url of the page after saving