Question: 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 askedto a user. The questions are asked in the order they areadded. Once a question has been asked it cannot be asked again.

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. Figure 2: An example of the data in the queue. (a) Redraw the queue diagram shown in Figure 2, after a new mathematical question " 55 " had been added into the queue. (a) Redraw the queue diagram shown in Figure 2, after a new mathematical question " 55 " had been added into the queue. (3 marks) (b) State the values stored in head and tail after the new mathematical question has been added as in question 2(a). (2 marks) (b) Explain why a queue is a suitable structure for this program. (3 marks) (c) Write the C++ code to define the node structure of the queue and to declare the two pointers used, head and tail. (5 marks) (d) Write the C++ code, to ask the user to input a new question and then add it to the queue. (6 marks) (e) Write the C++code to remove and output the first element of the queue. (6 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!