# SIGSEGV error in tsort

#include<stdio.h>
#define MAX 50

void mergeSort(int arr[],int low,int mid,int high);
void partition(int arr[],int low,int high);

int main(){
int t,i;
scanf("%d\n",&t);
int a[t];
for(i=0;i<t;i++)
scanf("%d",&a[i]);
partition(a,0,t-1);
for(i=0;i<t;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
void partition(int arr[],int low,int high){

``````int mid;

if(low<high){
mid=(low+high)/2;
partition(arr,low,mid);
partition(arr,mid+1,high);
mergeSort(arr,low,mid,high);
}
``````

}

void mergeSort(int arr[],int low,int mid,int high){

``````int i,m,k,l,temp[MAX];

l=low;
i=low;
m=mid+1;

while((l<=mid)&&(m<=high)){

if(arr[l]<=arr[m]){
temp[i]=arr[l];
l++;
}
else{
temp[i]=arr[m];
m++;
}
i++;
}

if(l>mid){
for(k=m;k<=high;k++){
temp[i]=arr[k];
i++;
}
}
else{
for(k=l;k<=mid;k++){
temp[i]=arr[k];
i++;
}
}

for(k=low;k<=high;k++){
arr[k]=temp[k];
}
``````

}

Format it properly ( post all of it as a code )

It is because T can be max 10^6 and initializing an array of 10^6 numbers it results in SIGSEGV.

Initialize an array in as static int, i.e.

```static int array[1000000];
```

and then use the arrayâ€¦

why does it work for static int?rishabhprsd7

//