Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

g Masimum Hesp Structure and Operations Wite a C++ progam that implements a Msxi

ID: 3773708 • Letter: G

Question








g Masimum Hesp Structure and Operations Wite a C++ progam that implements a Msximum Heap. in maximum heap, all parents are grester than their children arester than their chidren as shown in Figure 1. You should store maximum heap in an array in the Heap array, store heap struct objects that include id, name and age attributes shown below leap Objert ld Figure 1. Heap Object Representation inglement operations that are listed below Add element according to id value of the heap obiect {15 points), Remove Maximum elementiremove maximum ii) (is points) Display Heap Elements C10 points). Sort heap Kcorang to age information of heap otects with Ick sort method and display new heap view (15 points) In main, create heap with size 10, Then create user menu that is shown in Output (S points), Pat commands to your source code (10 points) creating Heap struct (5 pointsi and constructor (S points) Creating Heap Class Idefining function prototypes, attributes) and implementing other methods related to Heap class (isEmpty, reaching left, right and parent index) points tran..ner based mers. unti user presses-1. Therefore, udim pressng-1, user will qut trom the progam (2 poiets

Explanation / Answer

/* * C++ Program to Implement Max Heap */ #include #include using namespace std; void max_heapify(int *a, int i, int n) { int j, temp; temp = a[i]; j = 2 * i; while (j a[j]) break; else if (temp = 1; i--) { max_heapify(a,i,n); } } int main() { int n, i, x; coutn; int a[20]; for (i = 1; i