implement heap data structure 10
implement heap data structure 10
class HEAP {
public:
void MAX_HEAPIFY(int [], int, int);
void BUILD_MAX_HEAP(int [], int);
void HEAPSORT(int [], int);
void ACCEPT();
void DISPLAY(int [], int);
};
void HEAP::ACCEPT() {
int n;
cout << "\nEnter the number of students: ";
cin >> n;
int a[n + 1]; // Array to store heap (1-based indexing)
cout << "\nEnter the marks of the students:" << endl;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
HEAPSORT(a, n); // Sort using heap sort
DISPLAY(a, n); // Display sorted marks
}
int main() {
HEAP h;
h.ACCEPT();
return 0;
}