Skip to content
ExamSpine

Answer it

Inserting into the middle of a linked list

5 marksYou mark it yourself against the marking points

A music app keeps a playlist as a singly linked list. Each node holds a song and a reference to the next node. The last node's reference is null (in Python, None).

head -> [Rain] -> [Tide] -> [Wolf] -> null

The user wants a new song, Moss, to play straight after Tide. A reference current already points to the Tide node.

(a) Describe the steps needed to insert a new node holding Moss after Tide, in the right order. [3]

(b) Explain one advantage and one disadvantage of a linked list, compared with an array, for a playlist that changes often. [2]

[5]

Report a problem with this page