Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A program stores a queue of mathematical questions to be asked to a user. The questions are asked in the order they are added. Once

A program stores a queue of mathematical questions to be asked to a user. The questions are asked in the order they are added. Once a question has been asked it cannot be asked again. New questions are continually added to the end of the queue. The program will use a queue implemented using linked list to store the questions. The pointer, head, stores the address of the first element in the queue. The pointer, tail, stores the address of the last element in the queue. Figure 2 shows an example of the data in the queue.

(a) Redraw the queue diagram shown in Figure 2, after a new mathematical question 5 x 5 had been added into the queue.

(b) State the values stored in head and tail after the new mathematical question has been added as in question 2(a).

(c) Explain why a queue is a suitable structure for this program.

(d) Write the C++ code to define the node structure of the queue and to declare the two pointers used, head and tail.

(e) Write the C++ code, to ask the user to input a new question and then add it to the queue.

(f) Write the C++ code to remove and output the first element of the 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_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 Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

Design an internal skills transfer system through tutoring.

Answered: 1 week ago