#include #include #include using namespace std; void heapSort(int a[], int n); int main(){ int a[4] = {7, 2, 4, 9}; priority_queue , greater > h; heapSort(a, 4); for (int i = 0; i < 4; i++){ cout << a[i] << endl; } return 0; } void heapSort(int a[], int n){ priority_queue , greater > h; int x, k; for (int i = 0; i < n; i++){ x = a[i]; h.push(x); } k = 0; while (!h.empty()){ x = h.top(); h.pop(); a[k] = x; k++; } }