Question: C++ Read the attached document, queues.pdf, and then develop a program that implements a queue class (which implements the queue data structure). The external interface
C++
Read the attached document, queues.pdf, and then develop a program that implements a queue class (which implements the queue data structure). The external interface of your class shall be composed of functions that allow enqueuing character values into the queue and also dequeuing them from the queue. Your class shall implement ONE character array of size ARR_SIZE, which shall be a macro defined in the same header file where the class is declared (with a value of 30 for now). I will be changing this macro (ARR_SIZE) so make sure your program works properly for all legitimate values. Example: #define ARR_SIZE 30 The class shall use some data members, as described in queues.pdf (i.e. head, tail and count) and any other data member that you identify to be necessary for your code to function. Your class shall obviously implement the two interface functions for the enqueue and dequeue operations. Your program shall contain 3 files: queue.h (for class declaration), queue.cpp (for class member functions definition), and main.cpp (for your main routine). In your main routine, you shall instantiate a queue object and then enqueue the characters of the sentence Hello, World!, character by character (note that space is also a character) into that queue object (using the enqueue member function). You shall then dequeue characters from your queue object and display them, character-bycharacter, on the screen till the queue is empty (without adding any space or newline characters of your own). DO NOT use the queue in the STL library or any other library, you need to develop the code yourself.
Queues.pdf
Queue: a FIFO (first in, first out) data structure. Examples: people in line at the theatre box office print jobs sent to a printer Input from a keyboard is buffered into a stream using a fixed size FIFO. Implementation: static: fixed size, implemented as array dynamic: variable size, implemented as linked list
The queue data structure - Design/algorithms Create a buffer of length n Create some variables : (all initialized to zero) Use a variable (tail or write_index) to hold the index where new data should be written. Use a variable (head or read_index) to point to the array index from which data may be read. A count variable to hold the current number of elements in the array. Before enqueuing, make sure that counter < n (i.e. there is room for adding an entry). If not, return a failure. To enqueue an entry, write it to the array using the tail variable and then increment the head using modulo n arithmetic. Also increment the counter. Before dequeuing, make sure that counter > 0, else return a failure. To dequeue an entry, read it out using the head variable, decrement the head using modulo n arithmetic and also decrement the counter.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
