ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
4 marks · Linked lists
Explain why this ticket order queue will be implemented as a single linked list rather than a double linked list. The diagram below shows the contents of the linked list with details of several customers who are in the queue waiting to buy tickets. AmyR is stored in memory location 187 and will be the next customer able to purchase tickets. Head 115 PaulH Null 187 241 193 325 AmyR JulieD ClaraL AliM 241 193 325 115 Describe the changes that will take place within the linked list when user AmyR completes her purchase. Describe the changes that will take place within the linked list when user ClaraL closes her browser. Describe the changes that will take place within the linked list when a new user, SamK, joins the queue. Assume that his username is stored in memory location 227. A ticketing website manages demand for newly released tickets by using a queue to store details of customers who are waiting to purchase tickets. The ticket queue will be implemented as a single linked list. When tickets for events are released, the details of customers who wish to purchase tickets are added to the end of the linked list. As customers complete or cancel their purchases, their details are removed from the front of the linked list. If someone in the queue closes their browser, they lose their position in the queue and their details are removed from the linked list.
The list simply needs to move in one direction, starting from the first node on the list and working backwards though each item in the list. Once the first item has been processed, it is removed from the list and the next item is processed. There is never any need to move forwards. Award 1 mark for explanation that indicates that traversing in one direction is all that is needed. The Head of the list will now point to memory location 241, and the node with AmyR is removed from the list. Award 1 mark for updating head. The pointer from the node at memory location 241 is changed to point at memory location 325 and the node with ClaraL is removed. Award 1 mark for updating pointer for node 241. A node at memory location 227 is created. The pointer from the node at memory location 115 is changed to point to the new node at memory location 227. The pointer from this new node is set to point to Null. Award 1 mark for updating pointer for node 115 and setting pointer of new node to Null.