Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Answer ifndef QUEUEH define QUEUEH include iostream include string class Queue private stdstring ele... 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

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Operating System questions

Question

Working with athletes who dope

Answered: 1 week ago