Implement the queue class as shown above. Use your queue to store the names of 5 students waiting outside Student Services to meet with advisors. You may want to add more data to each node including student ID, Major, etc. Add a member function displayQueue which displays the contents of the queue. Write the main function to test the queue. Call your program ex6_1.cpp. Be sure to show the contents of queue after adding or removing each student. It is strongly encouraged that you make your program more user friendly by providing a menu of options for user (for example: user can choose to add an element to the queue or remove it or display entire queue).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In C++,

 

1
2
7
8
9
10
11
DISPLAY 13.20 A Queue
5 namespace queuesavitch
6
12
13
14
15
16
17
18
19
20
{
1:1
The operation to add an item in the queue is called push or enqueue operation and will always use
rear pointer. The operation to remove an item from the queue is called pop or dequeue operation
and will always use front pointer. The queue implementation will look like this:
DISPLAY 13.21
Interface File for a Queue Class (part 1 of 2)
//This is the header file queue.h. This is the interface for the class Queue,
//which is a class for a queue of symbols.
3
#ifndef QUEUE_H
4 #define QUEUE_H
struct QueueNode
{
B
char data;
QueueNode *link;
};
typedef QueueNode* QueueNodePtr;
class Queue
{
public:
B
A
|d
с
||
Queue ();
//Initializes the object to an empty queue.
Queue (const Queue& aQueue);
~Queue ();
A
Transcribed Image Text:1 2 7 8 9 10 11 DISPLAY 13.20 A Queue 5 namespace queuesavitch 6 12 13 14 15 16 17 18 19 20 { 1:1 The operation to add an item in the queue is called push or enqueue operation and will always use rear pointer. The operation to remove an item from the queue is called pop or dequeue operation and will always use front pointer. The queue implementation will look like this: DISPLAY 13.21 Interface File for a Queue Class (part 1 of 2) //This is the header file queue.h. This is the interface for the class Queue, //which is a class for a queue of symbols. 3 #ifndef QUEUE_H 4 #define QUEUE_H struct QueueNode { B char data; QueueNode *link; }; typedef QueueNode* QueueNodePtr; class Queue { public: B A |d с || Queue (); //Initializes the object to an empty queue. Queue (const Queue& aQueue); ~Queue (); A
DISPLAY 13.21 Interface File for a Queue Class (part 2 of 2)
void add(char item);
//Postcondition: item has been added to the back of the queue.
char remove();
//Precondition: The queue is not empty.
//Returns the item at the front of the queue and
//removes that item from the queue.
21
22
2148
23
24
25
26
27
78
bool empty() const;
//Returns true if the queue is empty. Returns false otherwise.
28
29
30
31
32
33
34
};
35
}//queuesavitch
36 #endif //QUEUE_H
private:
QueueNodePtr front;//Points to the head of a linked list.
//Items are removed at the head
QueueNodePtr back;//Points to the node at the other end of the
//linked list. Items are added at this end.
Exercise 6.1
Implement the queue class as shown above. Use your queue to store the names of 5 students
waiting outside Student Services to meet with advisors. You may want to add more data to each
node including student ID, Major, etc.
Add a member function displayQueue which displays the contents of the queue. Write the main
function to test the queue. Call your program ex6_1.cpp. Be sure to show the contents of queue
after adding or removing each student.
It is strongly encouraged that you make your program more user friendly by providing a menu of
options for user (for example: user can choose to add an element to the queue or remove it or
display entire queue).
Note: Queue can be implemented using arrays as well as linked list. This exercise requires you to
implement the linked list version of queues but you should also look at the array implementation
to enhance your understanding.
Transcribed Image Text:DISPLAY 13.21 Interface File for a Queue Class (part 2 of 2) void add(char item); //Postcondition: item has been added to the back of the queue. char remove(); //Precondition: The queue is not empty. //Returns the item at the front of the queue and //removes that item from the queue. 21 22 2148 23 24 25 26 27 78 bool empty() const; //Returns true if the queue is empty. Returns false otherwise. 28 29 30 31 32 33 34 }; 35 }//queuesavitch 36 #endif //QUEUE_H private: QueueNodePtr front;//Points to the head of a linked list. //Items are removed at the head QueueNodePtr back;//Points to the node at the other end of the //linked list. Items are added at this end. Exercise 6.1 Implement the queue class as shown above. Use your queue to store the names of 5 students waiting outside Student Services to meet with advisors. You may want to add more data to each node including student ID, Major, etc. Add a member function displayQueue which displays the contents of the queue. Write the main function to test the queue. Call your program ex6_1.cpp. Be sure to show the contents of queue after adding or removing each student. It is strongly encouraged that you make your program more user friendly by providing a menu of options for user (for example: user can choose to add an element to the queue or remove it or display entire queue). Note: Queue can be implemented using arrays as well as linked list. This exercise requires you to implement the linked list version of queues but you should also look at the array implementation to enhance your understanding.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education