# Turbo sort

tHIS PROGRAM IS GIVING DESIRED OUTPUT. but runtime error is shown after submission.

///////////////////////////////////////////////////
#include<stdio.h>
int main()
{
int k,t,i,n,swap;
int arr[10^6];
scanf("%d",&n);
if (n<=10^6)
for (t=0;t<n;t++)
{
scanf("%d",&arr[t]); // array is prepared
}

//////////////////////////////////////////////////////////////////

``````for (t=0;t<n-1;t++)
{
for (k=0;k<n-1;k++)
{
if (arr[k]>arr[k+1])
{
swap = arr[k];
arr[k] = arr[k+1];
arr[k+1] = swap;
}
}
}
for (t=0;t<n;t++)
printf("\n%d\n",arr[t]);
``````

return 0;
}

You have used the wrong operator ^ for 10^6.This is an XOR operator,not used for exponentiation . SO it ll create an array of size 10 XOR 6.Instead u can write 10000001. ANd also u shd change algo as it ll cause TLE

But now it is showing time limit exceeded , after making changes you suggested.

ya thts why u shd change ur algo. Use counting sort

Use better sorting algorithms like Merge Sort or Quick Sortâ€¦

For this problem Counting Sort is the best sort, just google it and try to implement it for this problemâ€¦

thanx , I will try it.