Question: The program below is for a linear queue using an array. The Queue class runs appropriately, but as a linear queue, it suffers from the

The program below is for a linear queue using an array. The "Queue" class runs appropriately, but as a linear queue, it suffers from the "Rightward Drifting" problem, which we discussed in class.
Part 1:
Avoid this problem by converting your Queue into a circular one (using an array as well) and show the changes you made to the code below. Use the same array size (10) and update the functions correctly. Make sure that the Queue can fit ten elements at once and utilize the whole array. In the sample run below, the Queue below fits only 7 because of the rightward drifting problem. Must solve the problem using the concept covered in the slides. Write comments next to the parts that you updated.
Part 2:
Use the same main function (sample run) below to test your new code and make sure that the updated Queue size is 10. Show the contents of the Queue at the end. Also, update the print function to work properly. The provided print function is not capable of handling circular queues. Write comments next to the parts that you updated.
Part 3:
Test your print function by filling the circular Queue with only two items:
x : at the front of the Queue in index 9
Y : at the back of the Queue, but in index 0
Must show the main function with your enqueue and dequeue operations that will place x at the 9th (front) and Y at the back in index zero.
Hinclude
 The program below is for a linear queue using an array.

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!