This is my code, and I am not able to find out where am I going wrong.
void heapify(int arr[], int n)
{
int i=n/2 , j, temp;
for(i=n/2; i>0; i--)
{
if(arr[2i]<arr[i])
{
temp = arr[2i];
arr[2i]= arr[i];
arr[i]= temp;
}
if(arr[2i+1]<arr[i])
{
temp = arr[2i];
arr[2i]= arr[i];
arr[i]= temp;
}
}
printf("Output:\n");
for(j=1; j<=n; j++)
{
printf("%d ", arr[j]);
}
}
int main()
{
int arr[11]={0,12,54,21,74,1,46,91,13,76,22}, n=10;
heapify(arr, n);
return 0;
}
It throws up the following error:
[Error] invalid types 'int*[__complex__ int]' for array subscript
Please help..Am struggling to implement heapsort here. Thanks in advance