Answered step by step
Verified Expert Solution
Link Copied!

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 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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions