User interface language: English | Español

Date November 2018 Marks available 3 Reference code 18N.1.HL.TZ0.11
Level HL Paper 1 Time zone no time zone
Command term Sketch Question number 11 Adapted from N/A

Question

The names of vegetables must be always held in alphabetical order in a list in the main memory.

The application program should allow insertion and deletion of the names of vegetables from this list.

Given the following vegetables: potato, asparagus, lettuce, radish.

Compare the use of a dynamic linked list for holding these names of vegetables with a static one-dimensional array.

[3]
a.

Sketch a single linked list holding these vegetables.

[2]
b.

List the steps required to insert cabbage into the linked list.

[4]
c.i.

Explain why deleting the first node in this list is different to deleting other nodes.

[2]
c.ii.

State the dynamic data structure suitable for maintaining this list of vegetables which will allow faster searching for a given vegetable name.

[1]
d.

The vegetable names are input in the following order

potato, asparagus, lettuce, radish.

Sketch the data structure suggested in part (d) containing the vegetable names sorted in alphabetical order.

[3]
e.

Markscheme

Award [1] for each comparison, up to [3 max].

The size of the dynamic list does not have to be predetermined as in an array;
The size of the dynamic list is not fixed whilst the size of an array is always fixed;
If names are sorted they can be added/deleted (more easily) by changing the pointers without having to shuffle the names;
As records can be dynamically added/deleted the memory is better used because there are no wasted / missing spaces as in an array;

a.

Award [1] for a node containing two fields / data(name) and link (pointer) to the next node and [1] for showing an external pointer pointing to the first vegetable on the list, and null pointer in the last node, and pointers which link the nodes in alphabetical order up to [2 max].

b.

Award [1] for each step identified up to [4 max].

Create a new node containing cabbage;
Traverse the list (from the beginning) to find the place to insert a new node;
Cabbage should be inserted before lettuce and after asparagus;
The pointer in new (cabbage) node should be set to point to the node that is before the insertion point / lettuce;
The pointer in node before insertion point / asparagus / should now point to the new node / cabbage;

Note: award marks for clearly labelled diagrams in candidates’ answers.

c.i.

Award [1] for identifying a reason why deleting the first node is different to deleting other nodes and [1] for an expansion up to [2 max].

External pointer (First) must be changed/only in situation when deleting the beginning node the external pointer must be changed;
And set to the pointer in the link field of the first node (Asparagus) which points to the second node/Lettuce;

c.ii.

Award [1 max].

Binary tree;

d.

Award [3 max].

Award [1] for clearly a binary tree and the root is Potato.
Award [1] for the correct left subtree.
Award [1] for the correct right subtree.

e.

Examiners report

[N/A]
a.
[N/A]
b.
[N/A]
c.i.
[N/A]
c.ii.
[N/A]
d.
[N/A]
e.

Syllabus sections

Topic 5: Abstract data structures » 5.1 Abstract data structures
Show 80 related questions
Topic 5: Abstract data structures

View options