- Subjects
- Computer Science
- Question bank
- B4.1 Fundamentals of ADTs
B4.1 Fundamentals of ADTs questions for IB Computer Science
201 questions on Fundamentals of ADTs, written by Augment in the style of IB exam papers. Six of them are below in full, to answer on paper.
- IB Computer Science
- Part of B4 Abstract data types
- HL only
Questions by paper and level
| Paper | Questions |
|---|---|
| Paper 2 | 201 |
Counted on
Questions to try
Written by Augment in the style of IB exams, not past papers. Answer them on paper, then check each one against its markscheme with a free account.
A music streaming company is designing a new app. Before anyone writes code, the lead developer publishes a description of a Playlist abstract data type (ADT) with these operations:
Operation | Description |
|---|---|
| adds track |
| removes the first occurrence of track |
| returns the track after the one currently playing |
| returns true if the playlist holds no tracks |
- (a)
Define the term abstract data type.
2 marks
- (b)
The description does not say whether the tracks are stored in an array or in a linked list.
Outline why the description leaves this out.
2 marks
- (c)
Explain two benefits to the development team of agreeing the Playlist ADT before the code is written.
4 marks
A heritage railway keeps the order of the carriages in a train as a singly linked list. Each node holds a carriage ID and a reference to the next node. Figure 1 shows the list for today's train.

A diagonal line in a pointer field shows a null reference (None in Python, null in Java).
- (a)
State the carriage ID held in the node referenced by
head.1 mark
- (b)
State the value of the next pointer in the node that holds C17.
1 mark
- (c)
Outline how the node holding C03 is found, starting from
head.2 marks
- (d)
A new carriage, C30, is attached to the front of the train.
Sketch the linked list after C30 has been added, and state the order in which the two references must be changed.
3 marks
A web browser stores the pages a user has visited in a tab as a doubly linked list. A reference current points to the node of the page on screen. The Back button moves current to the previous node and the Forward button moves it to the next node.
- (a)
Outline why a doubly linked list is more suitable than a singly linked list for this feature.
2 marks
- (b)
The user presses Back twice, so
currentis now in the middle of the list, and then opens a new page from a link. The browser discards the pages that were ahead ofcurrentand adds the new page after it.Describe the changes made to the references when the new node is added.
3 marks
- (c)
Outline one disadvantage of using a doubly linked list rather than a singly linked list in this application.
2 marks
A school library lets students reserve books that are on loan. The reserved titles are held in a singly linked list. The list class is shown below.
Python
class ReservationList:
def __init__(self):
self.head = NoneJava
public class ReservationList {
private Node head;
public ReservationList() {
head = null;
}
}Each node holds a book title (a string) and a reference to the next node.
- (a)
Construct the class
Node, including a constructor that takes a title.3 marks
- (b)
Construct the method
add_to_front(Python) /addToFront(Java) that adds a new title at the start of the list.3 marks
- (c)
Construct the method
displaythat outputs every title in the list, from the first to the last.3 marks
- (d)
Construct the method
containsthat takes a title and returns true if that title is in the list and false otherwise. For example, if the list holds "Dune", "Emma" and "Holes",contains("Emma")returns true andcontains("Matilda")returns false.4 marks
- (e)
Explain why the library does not need to decide in advance how many reservations the list can hold.
2 marks
A small text editor stores each line of a document as a string. The developer must choose between an array of lines and a singly linked list of lines. Users often insert and delete lines in the middle of long documents, and the editor's Go to line command jumps straight to a given line number.
Evaluate the use of a singly linked list rather than an array to store the lines of a document.
5 marks
A board-game app keeps the players in turn order in a circular singly linked list. The reference current points to the player whose turn it is. Figure 1 shows the list during a five-player game.

The classes used are:
Python
class Node:
def __init__(self, name):
self.name = name
self.next = None
class TurnRing:
def __init__(self):
self.current = None # the player whose turn it isJava
public class Node {
String name;
Node next;
public Node(String name) {
this.name = name;
this.next = null;
}
}
public class TurnRing {
private Node current; // the player whose turn it is
}- (a)
Outline why a circular linked list is suitable for storing the turn order.
2 marks
- (b)
State the name of the player whose turn comes after Eli's.
1 mark
- (c)
Construct the method
next_player(Python) /nextPlayer(Java) that passes the turn to the next player and returns that player's name. You may assume the ring is not empty.2 marks
- (d)
Cy, the current player, is knocked out of the game and must be removed from the list.
Explain why the program must visit the other nodes in the ring to remove the node referenced by
current.3 marks
- (e)
Construct the method
remove_current(Python) /removeCurrent(Java) that removes the current player from the ring and passes the turn to the player after them. If the removed player was the only one left,currentmust become null (None).For example, in Figure 1, after the method runs the ring holds Ama, Bo, Dee and Eli and
currentpoints to Dee.6 marks
- (f)
Suggest how storing the players in a circular doubly linked list would change the removal in part (e).
2 marks
Practice all 201 in Augment
Free with an account. Every question has its markscheme, and Augment keeps the ones you got wrong so you can come back to them.
More on Fundamentals of ADTs
- B4.1 Fundamentals of ADTs notesWhat Fundamentals of ADTs covers, explained, with its key terms.
- IB Computer Science question bankEvery Computer Science topic counted, and one question from each with its markscheme.
- Computer Science exam formatEach Computer Science paper, how long it is and its share of the grade.
Check your answers in Augment
A free account opens all 201 questions on Fundamentals of ADTs with their markschemes, and keeps a record of what you have marked.