Getting runtime error on the code

I am getting runtime error on my code however the code is running for sample cases
#include<bits/stdc++.h>
using namespace std;

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

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

};

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

// Node *insertBST(Node *root,int d){
// //cout<<“d is”<<d<<endl;
// if(root==NULL){
// root= new Node(d);
// return root;
// }
// //cout<<“yo yo”;
// if(ddata)
// root->left=insertBST(root->left,d);
// else
// root->right=insertBST(root->right,d);
// return root;
// }

void pre(Node *root){
if(root==NULL){
return;
}
cout<data<<" ";

pre(root->left);
pre(root->right);

}

int main() {
int t;
cin>>t;
while(t–){
int n;
int d[n];
cin>>n;
for(int i=0;i<n;i++){
cin>>d[i];
}
Node* root= build(d,0,n-1);
pre(root);
}
return 0;
}