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

image text in transcribedimage text in transcribedimage text in transcribed

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

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

What are the three main elements to writing commercial music?

Answered: 1 week ago

Question

3. Define the roles individuals play in a group

Answered: 1 week ago