Question: provides a simple framework for a queue data structure. Implement the details for the operations for this basic queue data structure that will use an

provides a simple framework for a queue data structure. Implement the details for the operations for this basic queue data structure that will use an array of elements of type string. We will not use templates for this implementation. Provide the implementations details for the following class methods (i.e. operations): initialize(), empty(),  enqueue(string element), dequeue(), and nextElement(). Descriptions of most these methods are provided in the source code and in supplementary module in the Learning Activities area. The code in the Driver.cpp file will remain the same. 

 

Hint: Again, you only need to modify the areas in the Queue.h file by adding the necessary   code to implement the TODO areas as noted in the comments. The prototype for   the functions and everything else in the program must remain unchanged. You   must use the function signature for your implementation. 

 

Output: The   output for the program after the functions are implemented should appear as   follows: 

 

Queue properties:     empty = 1   max size = 20   current size = 0   top element = [None] 

 

Queue   properties:   empty = 0   max size = 20   current size = 10   top element = all 

 

Queue elements: 

  all     of   our   dreams     can   come   true     if   we   just 

 

Queue properties:     empty = 1   max size = 20   current size = 0   top element = [None] 

 

Queue elements: 

    The queue is empty! 

 

Queue   properties:   empty = 0   max size = 20   current size = 6   top element = have 

 

Queue elements: 

  have     the   courage   to     pursue   them 

 

 

** Press any key to continue ** 


/**
 * Driver.cpp - This file contains the driver code to test your
 *              Queue class implementation.
 *
 * Course: CS3330 Data Structures and Algorithms.
 * Author: Dr. Jack Davault
 */

#include
#include
#include

#include "Queue.h"

using namespace std;

int main(int argc, char **argv)
{
   Queue queue(20);
 
   queue.properties();

   // Add some nodes to the queue
   queue.enqueue("Remember");
   queue.enqueue("all");
   queue.enqueue("of");
   queue.enqueue("our");
   queue.enqueue("dreams");
   queue.enqueue("can");
   queue.enqueue("come");
   queue.enqueue("true");
   queue.dequeue();
   queue.enqueue("if");
   queue.enqueue("we");
   queue.enqueue("just");

   queue.properties();
   queue.print();
   
   // Initalize the queue
   queue.initialize();

   queue.properties();
   queue.print();

   // Add more nodes than the queue can hold
   queue.enqueue("have");
   queue.enqueue("the");
   queue.enqueue("courage");
   queue.enqueue("to");
   queue.enqueue("pursue");
   queue.enqueue("them");

   queue.properties();
   queue.print();

   cout << "\n** Press any key to continue **\n";
   getchar();
   
   return 0;
}

Step by Step Solution

3.55 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer ifndef QUEUEH define QUEUEH include iostream include string class Queue private stdstring ele... View full answer

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 Operating System Questions!