Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 :
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 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 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 :
Use the same main function sample run below to test your new code and make sure that the updated Queue size is 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 :
Test your print function by filling the circular Queue with only two items:
: at the front of the Queue in index
: at the back of the Queue, but in index
Must show the main function with your enqueue and dequeue operations that will place at the th front and at the back in index zero.
Hinclude
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started