A queue Abstract Data Type (ADT) has these associated operations: Create queue Add item to
Question:
A queue Abstract Data Type (ADT) has these associated operations:
– Create queue
– Add item to queue
– Remove item from queue
The queue ADT is to be implemented as a linked list of nodes.
Each node consists of data and a pointer to the next node.
a) The following operations are carried out:
Copy the diagram below and add appropriate labels to show the final state of the queue.
Use the space on the left as a workspace.
Show your final answer in the node shapes on the right:
b) Using pseudocode, a record type, Node, is declared as follows:
The statement
Reserves space for 10 nodes in array Queue.
i) The CreateQueue operation links all nodes and initialises the three
Pointers that need to be used: HeadPointer, TailPointer and FreePointer.
Copy and complete the diagram to show the value of all pointers after CreateQueue has been executed.
ii) The algorithm for adding a name to the queue is written, using pseudocode, as a procedure with the header:
Copy and complete the pseudocode for the procedure RemoveName.
Use the variables listed in the identifier table.
Step by Step Answer:
Cambridge International AS & A Level Computer Science
ISBN: 9781510457591
1st Edition
Authors: David Watson, Helen Williams