i have this code for TSORT…it works fine on my computer but gives run time error SIGSEGV …pls have a look at it and tell me whats the bug…thanks…
#include<stdio.h>
void partition(unsigned long long arr[],unsigned long long first,unsigned long last);
void m_sort(unsigned long long arr[],unsigned long long low,unsigned long long mid,unsigned long long high);
int main(void)
{
unsigned long long t,n,i=0;
unsigned long long arr[10^7];
scanf("%llu",&n);
t=n;
//accepting elements
while(t--)
{
scanf("%llu",&arr[i++]);
}
partition(arr,0,n-1);
for(i=0;i<n;i++)
printf("%llu\n",arr[i]);
return 0;
}
void partition(unsigned long long arr[],unsigned long long first,unsigned long last)
{
unsigned long long mid;
if(first<last)
{
mid=(first+last)/2;
partition(arr,first,mid);
partition(arr,mid+1,last);
m_sort(arr,first,mid,last);
}
}
void m_sort(unsigned long long arr[],unsigned long long low,unsigned long long mid,unsigned long long high)
{
unsigned long long temp[10^7];
unsigned long long k=low;
unsigned long long i=low;
unsigned long long m=mid+1;
while(i<=mid&&m<=high)
{
if(arr[i]<=arr[m])
{
temp[k++]=arr[i++];
}
else
{
temp[k++]=arr[m++];
}
}
if(i>mid)
{
while(m<=high)
{
temp[k++]=arr[m++];
}
}
else
{
while(i<=mid)
{
temp[k++]=arr[i++];
}
}
for(i=low;i<=high;i++)
{
arr[i]=temp[i];
}
}