Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following linked list implementation of FIFO QUEUE in C++ to add the following member function: o void peekAll(): display all the elements in

Complete the following linked list implementation of FIFO QUEUE in C++ to add the following member function: o void peekAll(): display all the elements in the queue. The elements stay in the queue after this operation. class QUEUE { private: struct node { int item; node* next; node(int x) { item = x; next = 0; } }; typedef node *link; link head, tail; public: QUEUE(int) { head = 0; } int empty() const { return head == 0; } void put(int x) { link t = tail; tail = new node(x); if (head == 0) head = tail; else t->next = tail; } int get() { int v = head->item; link t = head->next; delete head; head = t; return v; } void peekAll() { /* implement this part */ } }; 2. Write a C++ program that creates a queue of up to 100 integers, and then it does the following on users input (your program must check for conditions: e.g. no get when the queue is empty): P x: puts x into queue G : outputs the element at the head of the queue, and removes this element from the queue E : outputs empty if queue is empty; otherwise not empty F : displays the entire content of the queue in first-in first-out order; no change in the queue Example Dialogue (input can be read from a specific file, or can be directed to a file): E empty P 1 P 10 E not empty F 1 10 P 19 G 1 G 10 E not empty P 5 P 20 F 19 5 20 G 19 G 5 G 20 E empty G nothing to get; queue is empty F nothing to peek; queue is empty P 2 E not empty F 2

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago