DESCRIPTIONSThe clients are arriving to get passports. The arriving clients register at the window. Each arriving client has a priority number and name. The priority numbers vary from 1 to 10. Ten being the highest priority and 1 being the lowest. At 10:00 am, the passport office will start serving clients that had registered by then at the window. The clients will be served not in the order that they arrived but in the order of their priority. First, all with priority 10; then those with priority 9 and so on.To simulate the above, create an array based priority queue using max heap. Input registering clients one by one and enque them one by one into the priority queue. Each client input data will consist of client priority and name. Priority of -1 will indicate end of data. After all the clients are enqued, deque them from the priority queue one by one and display them one by one till priority queue becomes empty. See the test input data and the expected output below.TEST DATAInput Data3 Jim2 Judy7 Jill1 Jimmy10 Joe4 Jacob8 Joseph9 Josephine5 Jackie6 John-1Output10 Joe9 Josephine8 Joseph7 Jill6 John5 Jackie4 Jacob3 Jim2 Judy1 JimmyDEFINITIONSMax HeapMax Heap is a heap in which the parent is always smaller than all of its children.Min HeapMin Heap is a heap in which the parent is always smaller than all of its childrenArray Based Max HeapArray Based Max Heap is a max heap which is implemented using an array.Array Based Min HeapArray Based Min Heap is a min heap which is implemented using an array.Max Heap Priority QueueMax Heap Priority Queue is a priority queue which is a max heap before an enqueue or a dequeue operation is started. In carrying out any of these operations, its max heap property may be temporarily disturbed. However, at the completion of each of these operation, the priority queue must be a max heap again.Min Heap Priority QueueMin Heap Priority Queue is a priority queue which is a min heap before an enqueue or a dequeue operation is started. In carrying out any of these operations, its min heap property may be temporarily disturbed. However, at the completion of each of these operation, the priority queue must be a min heap again.IMPLEMENTATIONImplement the priority queue class using max heap array. The priority queue class would have functions: penque (the priority enque), pdeque (priority deque) and isEmpty. These functions are described below:penqueueThis method will be used to enqueue an item to the priority queue. This method will receive a customer recordas a parameter and queue it to the priority queue. The priority queue will be a miax heap before the method is called. During the operation, its max heap property may be temporarily disturbed. However, when the method returns, the queue will be a max heap again.pdequeuePre-condition: This method will be called only when the que is NOT empty.This method will be used to deque an item from the priority queue. This method will receive no parameter, It will deque an item from the priority queue and return it to the caller. The queue will be a max heap before the method is called. During the operation, the queue’s max heap property may be temporarily disturbed. However, when the method returns, the queue will be a max heap again.isEmptyThis method will return true or 1 if the queue is empty. Otherwise, it will return false or 0. This method can be called to ensure that the queue is not empty before calling the dequeue method above.ALGORITHMpenqueue(The heap array is a max heap).Increase the length of the heap array by 1.Store the item to be enqueued to the newly added last element of the heap array.(The heap array is a max heap except that the newly added last element may have disturbed the max heap property).Call maxreheapifyUpward to maxreheapify the heap array.(The heap array is a max heap again).pdequeue(The heap array is a max heap).Save the contents of the first element of the heap array.(This element will be returned at the end of the method).Copy the contents of the last element of the array in the first element of the array.Decrease the length of the heap array by 1.(The heap array is a max heap except that the newly copied first element may have disturbed the max heap).Call maxreheapifyDownward to maxreheapify the heap array.(The heap array is a max heap again).Return the earlier saved first element of the heap array.CODE For Recordsstruct RecType{int priority;char name [20];};struct NodeType{int priority;char name [20];NodeType * next;};class pque{private:RecType x[100];int lastIndex;void maxreheapifyUpward (RecType x [], int lastIndex);void maxreheapifyDownward (RecType x [], int lastIndex);int findLargeChildIndex (int parentIndex, int lastIndex);public:pque ();void penque (RecType r);RecType pdeque ( );bool isEmpty ( );};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 classbool 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" << endl;cin >> n;while (n>=0){penque(n);cout << "input number" << endl;cin >> n;}while (!isEmpty()){n = pdeque();cout << n << endl;}return 0;}bool isEmpty(){if (lastIndex < 0)return true;elsereturn false;}void penque (int n){lastIndex++;x[lastIndex]=n;maxreheapifyUpward(x,lastIndex);}int pdeque ( ){int returnValue = x[0];x[0]= x[lastIndex];lastIndex--;maxreheapifyDownward(x,lastIndex);return returnValue;}//maxreheapifyUpward//The code below is for an int heap array.//Modify this method so that it is for a record heap array.//Also fill in the unfilled part of the code.void maxreheapifyUpward (int x [], int lastIndex){int parentIndex;int childIndex = lastIndex;while (childIndex > 0 ){parentIndex = childIndex/2;if (x [childIndex] <= x [parentIndex])break;else{//swap values at child and at parent.//Update child to parentchildIndex = parentIndex;}}}//maxreheapifyDownward//The algorithm below is for an int heap array,//Modify this method so that it is for a record heap array.//Also fill in the unfilled part of the code.void maxreheapifyDownward (int x [], int lastIndex){int parentIndex = 0;int largeChildIndex;while (parentIndex < lastIndex){largeChildIndex = findLargeChildIndex (parentIndex, lastIndex);if (largeChildIndex < 0 || x [largeChildIndex] <= x [parentIndex])break;else{//swap value at parentIndex with value at largeChildIndex//update parentIndexparentIndex = largeChildIndex;}}}int findLargeChildIndex (int parentIndex, int lastIndex){int lChildIndex = (2 * parentIndex) + 1;int rChildIndex = (2 * parentIndex) + 2;//case both children existif (rChildIndex <= lastIndex && lChildIndex <= lastIndex){//compare value at rChildIndex and at lChildIndex//return the index where the value is larger}//case only left child existelse if (lChildIndex <= lastIndex){return lChildIndex;}//case both children missingelse{return -1;}}Code with a Record As In Assignment#include

Don't use plagiarized sources. Get Your Custom Essay on

C++ CODE using max heap

Just from $13/Page

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.