Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is C++. Write a queue class to implement a queue using a 2 directional linked list. Test the program with the following sequence of

Language is C++.

Write a queue class to implement a queue using a 2 directional linked list.

Test the program with the following sequence of code:

queue myQ; ( Use default constructor to initialize front and end to NULL. )

cout<< myQ.size() << endl; // number of elements in queue

myQ.dequeue(); // Try to deqeue when the queue is empty. Should catch UNDERFLOW

myQ.enqueue("Fred");

myQ.enqueue("Liv");

myQ.enqueue("Julie");

myQ.enqueue("Rich");

myQ.enqueue("William");

myQ.enqueue("Olo");

myQ.enqueue("Xi");

myQ.enqueue("Chu");

myQ.enqueue("Annie");

myQ.enqueue("Carlos");

myQ.enqueue("Tuyet");

myQ.enqueue("Sue");

cout<< myQ.front() << endl; // name at front, if not empty

cout<< myQ.end() << endl; // name at end, if not empty

cout<< myQ.size() << endl; // number of elements in queue

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;;

myQ.enqueue("Olive");

myQ.enqueue("Jim");

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;

cout<< myQ.front() << endl; // name at front, if not empty

cout<< myQ.end() << endl; // name at end, if not empty

cout<< myQ.size() << endl; // number of elements in queue

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

More Books

Students also viewed these Databases questions

Question

2. Describe the functions of communication

Answered: 1 week ago

Question

=+How might these stem from country and regional cultures?

Answered: 1 week ago