Function to implement the heap sort*/
| 25 | } |
| 26 | /*Function to implement the heap sort*/ |
| 27 | void heapSort(int a[], int n) |
| 28 | { |
| 29 | |
| 30 | for (int i = n / 2 - 1; i >= 0; i--) |
| 31 | heapify(a, n, i); |
| 32 | // One by one extract an element from heap |
| 33 | for (int i = n - 1; i >= 0; i--) { |
| 34 | /* Move current root element to end*/ |
| 35 | // swap a[0] with a[i] |
| 36 | int temp = a[0]; |
| 37 | a[0] = a[i]; |
| 38 | a[i] = temp; |
| 39 | |
| 40 | heapify(a, i, 0); |
| 41 | } |
| 42 | } |
| 43 | /* function to print the array elements */ |
| 44 | void printArr(int a[], int n) |
| 45 | { |