Experiment-6: Program To Implement Heap Sort Algorithm
Experiment-6: Program To Implement Heap Sort Algorithm
#include<iostream.h>
#include<conio.h>
int j, temp;
temp = a[i];
j = 2*i;
while (j <= n)
j = j+1;
break;
a[j/2] = a[j];
j = 2*j;
}
a[j/2] = temp;
return;
int i, temp;
temp = a[i];
a[i] = a[1];
a[1] = temp;
MaxHeapify(a, 1, i - 1);
int i;
MaxHeapify(a, i, n);
}
int main()
int n, i;
cin>>n;
n++;
int arr[n];
cin>>arr[i];
Build_MaxHeap(arr, n-1);
HeapSort(arr, n-1);
cout<<"->"<<arr[i];
return 0;
getch();
}