Question: C++ Implement a menu based program with the following array-based queue functions: ADD (an element to the end of queue) DELETE (an element from the

C++ Implement a menu based program with the following array-based queue functions:

ADD (an element to the end of queue)

DELETE (an element from the front of queue)

SHOW (all elements, starting at first, ending at last)

COUNT (total number of elements)

CLEAR (initialize queue)

trade-offs between the two representations:

Using the count will make IsEmpty() and IsFull() easy, although we'll have to make sure the count is updated properly in ADD() and DELETE(). We haven't explored how to determine emptiness/fullness with rear or whether doing so presents any challenges.

Using the count in ADD() is similar to using rear. In both cases, the front won't move. With the count, we'll have to use count to calculate at which position to add new values, making sure to wrap around the array if necessary. Similarly, with a rear we have to make sure the rear moves properly and wraps around.

Using the count in DELETE() is not more difficult than using rear. In both cases, the front has to move (and wrap around when necessary).

In your homework assignment you can use whichever representation seems the easiest /most logical to you.

A hint: a very useful auxiliary function to have would be next_ix (que_index). It will give you the next queue index (ix++ or 1 depending where in the queue you are). This will save you a lot of if statements in the long run.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!