Hi, I need help with my C++ code. Create a Priority Queue UsingHeap in C++ that simulates an airline

Hi, I need help with my C++ code. Create a Priority Queue UsingHeap in C++ that simulates an airline algorithm to determine thepriority of passengers who are wait-listed for a flight. It needsto imput the user name and the time that he/she has arrived to thegate. It calculates a priority key based upon arrival time at thegate. Code to use as reference struct RecType {           intpriority;           char name[20]; }; struct NodeType {           intpriority;           char name[20];           NodeType* next; }; class pque { private:           RecTypex[100];           intlastIndex;           voidmaxreheapifyUpward (RecType x [], int lastIndex);           voidmaxreheapifyDownward (RecType x [], int lastIndex);           intfindLargeChildIndex (int parentIndex, int lastIndex); public:           pque();           voidpenque (RecType r);           RecTypepdeque ( );           boolisEmpty ( ); }; CODE For Ints //The code below is for an int heap array. //Also this code doesn’t use a class //Parts of the code are missing and is so indicated. //Modify this code so that it is for a record heap array. //Modify this code so that it is for class bool isEmpty(); void penque (int x); int pdeque ( ); void maxreheapifyUpward (int x [], int lastIndex); void maxreheapifyDownward (int x [], int lastIndex); int findLargeChildIndex (int parentIndex, int lastIndex); int lastIndex = -1; int x[100]; int main() {     int n;     cout << “input number” <

> n;     while (n>=0)     {         penque(n);        cout << “inputnumber” << endl;        cin >> n;     }     while (!isEmpty())     {        n = pdeque();        cout << n <

0 )           {                   parentIndex = childIndex/2;                   if (x [childIndex] using namespace std; class pque { public:     struct RecType     {         int priority;         string name;     };     RecType x[100];     int lastIndex;     RecType userInput; private:     void maxreheapifyUpward (RecType x [], intlastIndex)     {         int parentIndex;         int childIndex =lastIndex;         while (childIndex> 0 )         {            parentIndex = childIndex/2;            if (x[childIndex].priority <= x[parentIndex].priority)                break;            else            {                ///swap values at child and at parent.                RecType tempIndex = x[childIndex];                x[childIndex] = x[parentIndex];                x[parentIndex] = tempIndex;                ///Update child to parent                childIndex = parentIndex;            }         }     }     void maxreheapifyDownward (RecType x [], intlastIndex)     {         int parentIndex =0;       int largeChildIndex;         ///cout << “himaxreheapifyDownward” << endl;         while (parentIndex< lastIndex)         {            ///cout << “hi maxreheapifyDownward 2” << endl;            largeChildIndex = findLargeChildIndex (x, parentIndex,lastIndex);            if (largeChildIndex < 0 || x[largeChildIndex].priority <= x[parentIndex].priority)                break;            else            {                ///swap value at parentIndex with value at largeChildIndex               RecType temp = x[parentIndex];                x[parentIndex] = x[largeChildIndex];                x[largeChildIndex] = temp;                ///update parentIndex                parentIndex = largeChildIndex;            }         }     }     int findLargeChildIndex (RecType x[], intparentIndex, int lastIndex)     {         int lChildIndex = (2* parentIndex) + 1;         int rChildIndex = (2* parentIndex) + 2;         //case both childrenexist         if (rChildIndex <=lastIndex && lChildIndex <= lastIndex)         {            ///compare value at rChildIndex and at lChildIndex            ///return the index where the value is smaller            if (x[rChildIndex].priority > x[lChildIndex].priority)            {                return rChildIndex;            }            else            {                return lChildIndex;            }         }         ///case only leftchild exist         else if (lChildIndex<= lastIndex)         {            return lChildIndex;         }         ///case both childrenmissing         else         {            return -1;         }     } public:     pque() {lastIndex=-1;}     void penque (int p, string n)     {         lastIndex++;         x[lastIndex].priority= p;         x[lastIndex].name =n;        maxreheapifyUpward(x,lastIndex);     }     RecType pdeque ()     {         RecType returnValue =x[0];         x[0] =x[lastIndex];         lastIndex–;        maxreheapifyDownward(x,lastIndex);         returnreturnValue;     }     bool isEmpty ()     {         if (lastIndex <0){return true;}         else{returnfalse;}     } }; int main() {     pque recordList;     while (recordList.userInput.priority >=0)     {         cout << “inputnumber” << endl;         cin >>recordList.userInput.priority;         if(recordList.userInput.priority == -1)         {            break;         }         cout << “inputname” << endl;         cin >>recordList.userInput.name;        recordList.penque(recordList.userInput.priority,recordList.userInput.name);     }     while (!recordList.isEmpty())     {        recordList.userInput =recordList.pdeque();        cout . . .


 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.