Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a template class Queue as defined by the following skeleton: template class Queue { private: NodeType * front; // It points to the front

Implement a template class Queue as defined by the following skeleton: template class Queue { private: NodeType* front; // It points to the front of a singly-linked list NodeType* rear; // It points to the end of a singly-linked list public: Queue( ); // default constructor: Queue is created and empty Queue(const Queue &x); // copy constructor: implicitly called // for a deep copy void MakeEmpty(); // Queue is made empty; you should deallocate all // the nodes of the linked list bool IsEmpty( ); // test if the queue is empty bool IsFull( ); // test if the queue is full; assume MAXITEM=5 int length( ); // return the number of elements in the queue void Print( ); // print the value of all elements in the queue in the sequence // from the front to rear void Enqueue(ItemType x); // insert x to the rear of the queue // Precondition: the queue is not full void Dequeue(ItemType &x); // delete the element from the front of the queue // Precondition: the queue is not empty

image text in transcribed

~Queue(); // Destructor: memory for the dynamic array needs to be deallocated }; In you main( ) routine, you need to test your class in the following cases: QueueIntQueue; int x; IntQueue.MakeEmpty(); IntQueue.Dequeue(x); IntQueue.Enqueue(10); IntQueue.Enqueue(20); IntQueue.Enqueue(30); IntQueue.Enqueue(40); cout FloatQueue; string y; FloatQueue.MakeEmpty(); FloatQueue.Dequeue(y); FloatQueue.Enqueue(bob); cout FloatQueue2 = FloatQueue; cout Question 2 Implement a template class Queue as defined by the following skeleton: class Queue NodeType ItemTypefront: It points to the front of a singly-linked list NodeType ItemTyperear,It points to the end of a singly-linked list public: Queue; default constructor: Queue is created and empty Queue(const Queue ItemType &x); lcopy constructor: implicitly called void MakeEmpty: Queue is made empty; you should deallocate all bool IsEmpty): test if the queue is empty for a deep copy W the nodes of the linked list bool IsFull: test if the queue is full: assume MAXITEM-S int length: retun the number of elements in the queue void Print: print the value of all elements in the queue in the sequence / from the front to rear void Enqueue(ItemType x): insert x to the rear of the queue void Dequeue(ItemType &x); delete the element from the front of the queue -Queue; Destructor: memory for the dynamic array needs to be deallocated Precondition: the queue is not full In you main) routine, you need to test your class in the following cases: int x (10) (20) 40) cout

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago