Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

16.11 Homework 6b: Circular Queue A circular queue (https://en.wikipedia.org/wiki/Circular_buffer) is one way to implement a queue in the computer. In this assignment, you will implement

image text in transcribedimage text in transcribed

16.11 Homework 6b: Circular Queue A circular queue (https://en.wikipedia.org/wiki/Circular_buffer) is one way to implement a queue in the computer. In this assignment, you will implement a CircularQueue class that stores chars, with the following characteristics .A circular queue is stored in an array In addition to the array, the data structure keeps track two indices in the array: a "start' position, and an end position. When an item is enqueued (added) to the queue, it is added at the end position. The end position is then incremented, wrapping around to zero it reaches the end of the array. To dequeue (remove and return) an item from the queue, we return the item at the start position, and increment the start position (once again wrapping around when it reaches the end of the array) If start and end are the same, then the queue is empty. If (end+1 ) % arrayLength-start, then the queue is full. To add another element to the queue, a new array must be allocated with twice the size of the current one, and all of the elements copied to it, starting at position 0. In C++, after the copying, the old array should be deleted to avoid a memory leak Write a class called CircularQueue, or something similar, that implements a circular queue for chars as described above, using an array of chars as the array storage. The queue should start out with an array of length 2. Write a program that uses your CircularQueue class to answer queries that either add letters to the queue, or remove them from the queue. When a letter is removed from the queue, print out both the letter's position in the array, and the letter itself

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

Step: 3

blur-text-image

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

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

Explain the various methods of job evaluation

Answered: 1 week ago