aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 8.1Building linked lists
Back to Computer Science HL Topics
8.1.36 min read

Building linked lists (Computer Science HL)

IB Computer Science · Unit 8

Smart study tools

Turn reading into results

Move beyond passive notes. Answer exam-style questions, get AI feedback, and build the skills that earn top marks.

Get Started Free

Contents

  1. 1The node, and the head
  2. 2Traversal, insertion, deletion
  3. 3The other two kinds in code
  4. 4Exam-style question
The big idea: Two things make a linked list: a Node that holds a value and a reference, and a head reference that points at the first node.
Lose the head: Lose the head and the whole list is unreachable. Nothing else points at the first node.
class Node:
    def __init__(self, value):
        self.value = value
        self.next = None      # nothing after it yet

head = Node("A")
head.next = Node("B")
head.next.next = Node("C")
# head -> A -> B -> C -> None
class Node {
    String value;
    Node next;                // nothing after it yet

    Node(String value) {
        this.value = value;
        this.next = null;
    }
}

Node head = new Node("A");
head.next = new Node("B");
head.next.next = new Node("C");
// head -> A -> B -> C -> null
None marks the end: The last node's next is None. That is the only thing distinguishing the end of the list from the middle of it — which is why every traversal tests for it.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
1

Traverse

Start at the head, do the work, move on. Stop when the reference runs out — when it is None.

2

Insert at the front

The cheapest operation there is — no traversal at all. Point the new node forwards first, then move the head onto it.

3

Insert after a node

Point the new node at prev's successor first, then repoint prev. Doing those two in the other order loses every node after prev.

4

Delete

Nothing is erased — the node is simply routed around. Once nothing references the target, it is unreachable.

# 1. Traverse
current = head
while current is not None:
    print(current.value)
    current = current.next

# 2. Insert at the front
new_node = Node("Z")
new_node.next = head     # point at the old first
head = new_node          # the new node IS the head

# 3. Insert after a node
new_node.next = prev.next    # point forwards FIRST
prev.next = new_node         # then repoint prev

# 4. Delete — route around the target
prev.next = target.next
1

Traverse

Start at the head, do the work, move on. Stop when the reference runs out — when it is null.

2

Insert at the front

The cheapest operation there is — no traversal at all. Point the new node forwards first, then move the head onto it.

3

Insert after a node

Point the new node at prev's successor first, then repoint prev. Doing those two in the other order loses every node after prev.

4

Delete

Nothing is erased — the node is simply routed around. Once nothing references the target, it is unreachable.

// 1. Traverse
Node current = head;
while (current != null) {
    System.out.println(current.value);
    current = current.next;
}

// 2. Insert at the front
Node newNode = new Node("Z");
newNode.next = head;     // point at the old first
head = newNode;          // the new node IS the head

// 3. Insert after a node
newNode.next = prev.next;    // point forwards FIRST
prev.next = newNode;         // then repoint prev

// 4. Delete — route around the target
prev.next = target.next;
Deleting the first node is the special case: There is no prev for the head. Deleting it means moving the head itself — head ← head.next.

An answer that handles only the middle case is incomplete, and this is the case examiners choose.

Feeling unprepared for exams?

Get a clear study plan, practice with real questions, and know exactly where you stand before exam day. No more guessing.

Get Exam Ready FreeYour first topic is free to keep • No credit card required
Doubly linkedCircular
Node holdsvalue, next, prevvalue, next
End of listnext is Nonenext points at the head
Traversal stops whencurrent is Nonecurrent is back at the head
Insertion updatesFour referencesTwo
Deleting needsOnly the node itselfThe node before it
Doubly linkedCircular
Node holdsvalue, next, prevvalue, next
End of listnext is nullnext points at the head
Traversal stops whencurrent is nullcurrent is back at the head
Insertion updatesFour referencesTwo
Deleting needsOnly the node itselfThe node before it
Four references, not two: Inserting into a doubly linked list updates the new node's next AND prev, the previous node's next, and the following node's prev.

Miss one and traversal works in one direction and breaks in the other — a bug that hides until something walks backwards.

A circular list never reaches None — the last node points back at the head — so the loop needs a different stop test:

current = head
while True:
    print(current.value)
    current = current.next
    if current is head:
        break
Circular traversal: The stop test is identity with the head, not None. Say that explicitly.

A circular list never reaches null — the last node points back at the head — so the loop needs a different stop test:

Node current = head;
while (true) {
    System.out.println(current.value);
    current = current.next;
    if (current == head) {
        break;
    }
}
Circular traversal: The stop test is identity with the head, not null. Say that explicitly.

How this is tested — you must write or trace the reference assignments in the right ORDER, and handle the head as a special case. It comes up two ways:

Paper 2 — working with code

  • Construct code for an operation, 4-6 marks
  • Trace what a list looks like after operations
  • Sketch the list as boxes and arrows

Paper 2 — the algorithmic-thinking question

  • Explain why an order of assignment matters
  • Identify the case an implementation fails on
The classic trap: Assigning prev.next ← new before new.next ← prev.next. The first assignment overwrites the only reference to the rest of the list, and everything after it is lost.
IB-style questionConstruct[5 marks]

Write a Python function that deletes the first node whose value equals a target from a singly linked list, handling the case where it is the head.

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic

IB Exam Questions on Building linked lists

Practice with IB-style questions filtered to Topic 8.1.3. Get instant AI feedback on every answer.

Practice Topic 8.1.3 QuestionsBrowse All Computer Science HL Topics

How Building linked lists Appears in IB Exams

Examiners use specific command terms when asking about this topic. Here's what to expect:

  • Define

    Give the precise meaning of key terms related to Building linked lists.

    AO1
  • Describe

    Give a detailed account of processes or features in Building linked lists.

    AO2
  • Explain

    Give reasons WHY — cause and effect within Building linked lists.

    AO3
  • Evaluate

    Weigh strengths AND limitations of approaches in Building linked lists.

    AO3
  • Discuss

    Present arguments FOR and AGAINST with a balanced conclusion.

    AO3

See the full IB Command Terms guide

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

8.1.1What ADTs are for8.1.2Evaluating linked lists8.1.4Binary search trees8.1.5Sets
View all Computer Science HL topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Computer Science HL
Previous8.1.2Evaluating linked listsNextBinary search trees8.1.4

19 questions to test your understanding

Reading is just the start. Students who tested themselves scored 82% on average — try IB-style questions with AI feedback.

Start FreeView All Computer Science HL Topics