IB COMPUTER SCIENCE · HIGHER LEVEL

IB Computer Science HL
May 2026 Past Papers

Every question from Paper 1, all four Paper 2 options (databases, modelling and simulation, web science and object-oriented programming) and the Paper 3 case study, solved step by step in friendly handwriting. Algorithms, SQL and Java are written out in full, with the reasoning behind each line.

  • 3 papers, all 4 options
  • 37 questions
  • 390 marks solved
  • Pseudocode, SQL and Java
  • Beginner-friendly

Updated

Illustrative student working through mathematics notes beside a laptop.

About the IB Computer Science HL May 2026 papers

IB Computer Science Higher Level is assessed by three written papers and an internal assessment. Paper 1 (100 marks) covers system fundamentals, computer organization, networks, computational thinking, abstract data structures, resource management and control. Paper 2 (65 marks) tests one option chosen by the school: A databases, B modelling and simulation, C web science or D object-oriented programming in Java. All four are solved here. Paper 3 (30 marks) is based on a case study released in advance; for 2026 it is “An ethical approach to hacking”, about penetration testing at a hospital.

The May 2026 papers solved on this page
PaperDate and sessionTimeQuestionsMarks
Paper 130 April 2026, afternoon2 hours 10 minutes15100
Paper 2 · Option A4 May 2026, morning1 hour 20 minutes465
Paper 2 · Option B4 May 2026, morning1 hour 20 minutes465
Paper 2 · Option C4 May 2026, morning1 hour 20 minutes565
Paper 2 · Option D4 May 2026, morning1 hour 20 minutes565
Paper 3 (case study)4 May 2026, morning1 hour430

The cover of each paper lists Zone A, Zone B and Zone C at the same time of day, so there is one version of each. Paper 1 was held on 30 April 2026 and Papers 2 and 3 on 4 May 2026.

How this page is made. The solutions are original and written for learners. Each question is restated by its mathematics, and every graph or diagram is redrawn from the numbers in the solution, so nothing here is a scan or a copy of an examination paper. This page is independent and is not published or endorsed by the International Baccalaureate. For official mark schemes, ask your teacher or see the IB assessment and exams information.

How to use these handwritten solutions

  1. Try the question first. Set a timer of about one minute per mark, and write your own working.
  2. Read the steps slowly. Each step says what is done and why, so you can follow the idea and not just copy the algebra.
  3. Mark yourself. Tick every step you also had. Those are method and accuracy marks you would have earned.
  4. Check the red notes. They show the slips that cost marks most often, such as forgetting a second solution or dividing by something that could be zero.
  5. Redo it in three days without looking. If you can finish it cleanly, the method has stuck.
Command terms in IB mathematics questions
Command termWhat you need to do
Identify / State / ListGive short answers with no explanation, usually one mark each.
DefineGive the precise meaning of a term.
OutlineGive a brief account: a point and a short expansion, often two marks.
DescribeGive a detailed account of how something works, step by step.
ExplainGive reasons or causes: say what happens and why.
ConstructWrite the algorithm in pseudocode or the method in code, so that it works for all cases.
Determine / TraceWork out the answer by following the algorithm, showing each step.
Evaluate / Justify / DiscussGive arguments for and against, linked to the context, and reach a conclusion.
Mark types in the IB mark scheme
CodeMeaning
PseudocodePaper 1 uses IB pseudocode. Logic counts more than exact syntax, but loops, conditions and returns must be clear.
JavaOption D answers are written in Java. Use the class’s existing methods where the question allows it.
ContextHigher-mark answers must refer to the scenario (the company, the taxi, the hospital), not just general facts.
LevelsLong Paper 3 answers are marked against level descriptors: depth, accuracy and a clear conclusion.

Paper 1 algorithms are written in IB pseudocode, Option A queries in SQL, Option B formulas in spreadsheet syntax and Option D answers in Java. The logic matters more than perfect syntax, but your algorithm must work for every case, including the first and last elements and an empty structure.

Choose a paper

COMPUTER SCIENCE HL · 30 APRIL 2026

IB Computer Science HL May 2026 Paper 1: worked solutions

  • 30 April 2026, afternoon
  • 2 hours 10 minutes
  • 100 marks
  • Paper code 2226-4428

Paper 1, Question 1: Comparing types of computers

3 marksSystem fundamentals and networks
The question

Identify three characteristics to consider when comparing different types of computers.

Identify three characteristics. [3]

[3 marks]

  1. Think about what makes a phone, a laptop, a server and a supercomputer different from each other.
  2. Any three of: processing speed (clock speed and number of cores), primary memory size (RAM), secondary storage capacity, size and portability, power consumption or battery life, cost, and the input/output devices available.

Answer:Processing speed; memory (RAM) and storage capacity; size and portability (any three, including cost or power consumption).

Watch out: “Identify” needs only short answers, one mark each.

Paper 1, Question 2: Shared resources on a LAN

2 marksSystem fundamentals and networks
The question

Identify two resources that can be shared on a local area network (LAN).

Identify two resources. [2]

[2 marks]

  1. A LAN lets the computers in one building share hardware, software and data.
  2. Examples: a printer or scanner, files and folders on a file server, an internet connection, shared software licences or databases.

Answer:A printer; files on a file server (or an internet connection).

Paper 1, Question 3: Stack method pop()

1 marksProgramming and data structures
The question

State the purpose of the stack access method pop().

State the purpose of pop(). [1]

[1 mark]

  1. A stack is last in, first out (LIFO). pop() works on the top of the stack only.

Answer:pop() removes the item at the top of the stack and returns it.

Paper 1, Question 4: Stack method isEmpty()

1 marksProgramming and data structures
The question

State the purpose of the stack access method isEmpty().

State the purpose of isEmpty(). [1]

[1 mark]

  1. Before calling pop() we need to know whether there is anything to remove.

Answer:isEmpty() returns TRUE if the stack contains no items and FALSE otherwise.

Paper 1, Question 5: Representing colour in binary

3 marksComputer organization and control
The question

Describe how colours are represented in a computer.

Describe how colours are represented. [3]

[3 marks]

  1. An image is made of pixels, and each pixel’s colour is stored as a binary number.
  2. In the RGB model each colour is a mix of red, green and blue. Each of the three components is usually stored in 8 bits, giving an intensity from 0 to 255.
  3. So one pixel needs 24 bits, which allows 224≈16.7 million different colours. Colours are often written in hexadecimal, for example #FF0000 for pure red.

Answer:Each pixel stores a binary value for the intensity of red, green and blue (usually 8 bits each, 24 bits in total), giving about 16.7 million colours, often written in hexadecimal.

Paper 1, Question 6: Truth table from a description

4 marksComputer organization and control
The question

A truth table has three inputs A, B and C and one output OUT. The inputs form a binary number ABC (for example A = 1, B = 0, C = 1 is 1012=510). OUT is 1 if the binary number has an odd number of 1s, or if its decimal value is odd. Otherwise OUT is 0. Zero is even. Construct the truth table.

Construct the truth table. [4]

Truth table for inputs A, B and C with the number of 1s, the decimal value and OUT. OUT is 1 for every row except 000 and 110.ABCNumber of 1sDecimalOUT000000001111010121011231100141101251110260111371
The completed truth table. OUT = 1 when the number of 1s is odd or the decimal value is odd.

[4 marks]

  1. List all 23=8 combinations of A, B and C in binary order from 000 to 111.
  2. A decimal value is odd exactly when the last bit C is 1. So every row with C = 1 has OUT = 1.
  3. For C = 0: 000 has zero 1s (even) and value 0 (even), so OUT = 0. 010 has one 1, so OUT = 1. 100 has one 1, so OUT = 1. 110 has two 1s and value 6, both even, so OUT = 0.
  4. Rows 000 to 111 give OUT = 0, 1, 1, 1, 1, 1, 0, 1.

Answer:OUT = 1 for every row except ABC = 000 and ABC = 110 (see the table).

Watch out: Check both conditions for each row. One true condition is enough for OUT = 1.

Paper 1, Question 7: Operations on a doubly linked list

4 marksProgramming and data structures
The question

A doubly linked list holds Ali (head), Zak, Kim, Mia (end). In order: Zak is deleted, the first node is deleted, the last node is deleted, and Ben is inserted at the beginning. Sketch the resulting doubly linked list.

Sketch the resulting list. [4]

Doubly linked list after the four operations: head points to Ben, Ben links both ways to Kim, end points to Kim. Ben’s previous pointer and Kim’s next pointer are null.nullBenKimnullHeadEndnext → ← previous
The resulting doubly linked list: Ben ⇄ Kim.

[4 marks]

  1. Start: Ali ⇄ Zak ⇄ Kim ⇄ Mia.
  2. Delete Zak: Ali ⇄ Kim ⇄ Mia (Ali’s next now points to Kim and Kim’s previous points to Ali).
  3. Delete the first node (Ali): Kim ⇄ Mia, and head moves to Kim. Then delete the last node (Mia): only Kim is left, and end points to Kim.
  4. Insert Ben at the beginning: Ben ⇄ Kim. Head points to Ben, end points to Kim. Ben’s previous pointer and Kim’s next pointer are null.

Answer:Head → Ben ⇄ Kim ← End, with null before Ben and null after Kim.

Watch out: Show both pointers in each node, the null pointers at each end, and the head and end labels.

Paper 1, Question 8: Network protocols

4 marksSystem fundamentals and networks
The question

Answer the parts about protocols.

(a) Define the term protocol. [1]

(b) List three reasons why protocols are necessary in computer networks. [3]

(a)[1 mark]

  1. A protocol is an agreed set of rules for how data is transmitted between devices on a network.

Answer:A set of rules that governs the transmission of data between devices.

(b)[3 marks]

  1. Any three of: to ensure data integrity (error checking); to manage flow control so a fast sender does not overwhelm a slow receiver; to avoid deadlock and manage congestion; to address and route packets to the correct destination; to let devices from different manufacturers communicate; to keep packets in the right sequence.

Answer:Data integrity (error detection), flow control, and compatibility between different devices (also addressing, routing, congestion control).

Paper 1, Question 9: Translators

1 marksProgramming and data structures
The question

State one computer program that translates code written in a high-level language into machine-readable code.

State one translator. [1]

[1 mark]

  1. A compiler translates the whole program into machine code before it runs. An interpreter translates and runs it line by line.

Answer:A compiler (or an interpreter).

Paper 1, Question 10: Debugging

2 marksProgramming and data structures
The question

Outline what is meant by debugging.

Outline debugging. [2]

[2 marks]

  1. Debugging is the process of finding, locating and correcting errors (bugs) in a program.
  2. Programmers use tools such as breakpoints, stepping through the code, trace tables and printing variable values to see where the program behaves wrongly.

Answer:Finding and fixing errors in a program, for example by using breakpoints, trace tables or a debugger.

Paper 1, Question 11: Prototypes, parallel running and email security

15 marksSystem fundamentals and networks
The question

A prototype for a company’s new computer system has been developed. After evaluation and revision, the new system is run in parallel with the old system. The company also promotes its services on the web and by email, and asks customers for their name, email address, home address and date of birth.

(a) State two reasons why the company might not proceed with the new system after evaluating the prototype. [2]

(b) Evaluate parallel running as part of a system installation process. [4]

(c)(i) List three threats to the security of the data collected by the company. [3]

(c)(ii) State the purpose of an email server. [1]

(c)(iii) State two benefits of using email for communication among employees. [2]

(c)(iv) Explain the need for encryption in email communication. [3]

(a)[2 marks]

  1. A prototype shows how the system will work before it is fully built, so problems can be found early.
  2. Reasons to stop: the users find it does not meet their requirements; the full system would cost too much or take too long; it is not technically feasible with the company’s hardware.

Answer:The prototype shows that the system does not meet the users’ needs; the full system would be too expensive or take too long to build.

(b)[4 marks]

  1. Advantage: the old system keeps running, so if the new system fails no data or service is lost. It is a safe backup.
  2. Advantage: the outputs of both systems can be compared to check that the new one gives correct results.
  3. Disadvantage: staff have to enter every transaction twice, which doubles the workload and the cost, and can cause errors if the two systems disagree.
  4. Conclusion: parallel running is the safest method and is worth the extra cost for critical systems where failure is unacceptable, but it is expensive for large or non-critical systems.

Answer:It is very safe (the old system is a backup and results can be compared) but costly and time-consuming (double data entry, more staff). It suits critical systems.

Watch out: “Evaluate” needs both sides and a conclusion.

(c)(i)[3 marks]

  1. Think of who or what could read, change or destroy the customer data.

Answer:Hackers gaining unauthorized access; malware such as viruses or ransomware; phishing attacks on staff (also interception of data, insider misuse, data loss).

(c)(ii)[1 mark]

  1. An email server stores incoming emails in users’ mailboxes and sends outgoing emails to other servers (using protocols such as SMTP and IMAP).

Answer:To send, receive and store emails for its users.

(c)(iii)[2 marks]

  1. Email is fast and cheap, can be sent to many people at once, can carry attachments and keeps a written record.

Answer:It is fast (and free) and it keeps a written record that can be searched later (also attachments, many recipients).

(c)(iv)[3 marks]

  1. An email passes through several networks and servers before it arrives, so it could be intercepted on the way.
  2. Encryption scrambles the message with a key, so anyone who intercepts it sees only unreadable ciphertext. Only the intended receiver with the key can decrypt it.
  3. This protects confidential information such as customers’ addresses and dates of birth from identity theft, and helps the company meet data protection laws.

Answer:Emails can be intercepted in transit; encryption makes them unreadable without the key, protecting personal data and keeping the company within the law.

Paper 1, Question 12: Memory, the operating system and the CPU

15 marksComputer organization and control
The question

Answer the parts about memory and the components of the CPU.

(a)(i) Distinguish between primary memory and secondary memory. [3]

(a)(ii) Outline two functions of an operating system (OS) in managing primary memory. [4]

(b)(i) State the role of the memory data register (MDR). [1]

(b)(ii) Explain the use of cache memory. [3]

(b)(iii) Explain the role of buses in CPU operations. [4]

(a)(i)[3 marks]

  1. Primary memory (RAM and ROM) is directly accessed by the CPU. It holds the programs and data currently in use, is fast, and RAM is volatile (it loses its contents when the power is off).
  2. Secondary memory (hard disk, SSD, USB) is not directly accessed by the CPU. It is non-volatile, slower, larger and cheaper per byte, and is used for long-term storage.

Answer:Primary memory is directly accessible by the CPU, fast and (RAM) volatile; secondary memory is non-volatile, slower and larger, and stores data permanently.

(a)(ii)[4 marks]

  1. Memory allocation: the OS allocates a region of RAM to each program when it starts and frees it when the program ends, keeping track of which areas are used and free.
  2. Memory protection: the OS stops one process from reading or changing the memory of another process (or of the OS itself).
  3. (Also: virtual memory and paging, where the OS moves pages between RAM and secondary storage when RAM is full.)

Answer:Allocating and freeing memory for each process; protecting each process’s memory from the others (also managing virtual memory/paging).

(b)(i)[1 mark]

  1. The MDR is the register that holds data on its way to or from memory.

Answer:The MDR holds the data or instruction that has just been read from memory, or that is about to be written to memory.

(b)(ii)[3 marks]

  1. Cache is a small amount of very fast memory between the CPU and RAM, often inside the CPU itself (levels L1, L2, L3).
  2. It stores copies of frequently or recently used instructions and data. The CPU checks the cache first. If the data is there (a cache hit), it avoids a slower trip to RAM.
  3. This reduces the time the CPU waits for data, so programs run faster.

Answer:Cache is fast memory holding frequently used data and instructions, so the CPU can fetch them without accessing slower RAM, which speeds up processing.

(b)(iii)[4 marks]

  1. Buses are sets of wires that carry signals between the CPU, memory and input/output devices.
  2. The address bus carries the memory address (from the MAR) of the location to be read or written. It is one-way, from the CPU.
  3. The data bus carries the data or instruction itself between memory and the CPU (into the MDR). It is two-way.
  4. The control bus carries control signals such as read/write, clock and interrupts. For example, in the fetch stage the address goes on the address bus, a read signal on the control bus, and the instruction returns on the data bus.

Answer:The address bus carries addresses, the data bus carries data and instructions, and the control bus carries signals such as read/write, so the CPU can fetch and store data in memory.

Paper 1, Question 13: Taxi meters and GPS

15 marksComputer organization and control
The question

A taxi meter calculates fares from distance and time, displays the fare in real time, applies a preset rate and lets the driver add extra charges. Taxi companies also use GPS-enabled apps on smartphones to measure the distance of a trip and calculate the fare.

(a)(i) Identify two input devices that could be used to collect the data needed to calculate the fare. [2]

(a)(ii) Describe the use of a microprocessor in a taxi meter. [3]

(b)(i) Explain how GPS works. [6]

(b)(ii) State two benefits of a GPS-enabled taxi app for passengers. [2]

(b)(iii) State two benefits of a GPS-enabled taxi app for taxi drivers. [2]

(a)(i)[2 marks]

  1. The meter needs the distance, the time and any extras.

Answer:A distance sensor (for example a wheel-rotation sensor or GPS receiver) and a keypad or touchscreen for the driver to enter extra charges (also a clock/timer).

(a)(ii)[3 marks]

  1. The microprocessor continuously reads input from the distance sensor, the timer and the driver’s keypad.
  2. It applies the preset rates stored in memory: fare = (distance × rate) + (time × rate) + extras.
  3. It sends the updated fare to the display many times a second, so passengers see it in real time.

Answer:It repeatedly reads the sensor and keypad inputs, calculates the fare using the stored rates, and outputs the result to the display in real time.

(b)(i)[6 marks]

  1. GPS uses a network of about 24 to 31 satellites orbiting the Earth, arranged so that at least four are visible from anywhere.
  2. Each satellite has a very accurate atomic clock and continuously broadcasts a signal containing its position and the exact time the signal was sent.
  3. The receiver (in the smartphone) picks up signals from at least four satellites and measures how long each signal took to arrive.
  4. Distance to each satellite = speed of light × travel time.
  5. Trilateration: knowing the distances to three satellites places the receiver where three spheres meet. The fourth satellite corrects the error in the receiver’s cheaper clock.
  6. The receiver repeats this every second or so. Successive positions give the route, the distance travelled and the speed, which the app uses for the fare.

Answer:Satellites broadcast their position and the time; the receiver measures the travel time from at least four satellites, converts it to distances and uses trilateration to find its position, repeating to track distance.

Watch out: For 6 marks, cover satellites, timing signals, distance from time, at least four satellites and trilateration.

(b)(ii)[2 marks]

  1. Think about what the passenger can see before and during the trip.

Answer:They see the fare or an estimate before the trip; they can track the route and the taxi’s arrival (also safety, cashless payment).

(b)(iii)[2 marks]

  1. Think about navigation and finding customers.

Answer:Navigation to the passenger and the destination; automatic, accurate fares that avoid disputes (also finding nearby passengers, a record of earnings).

Paper 1, Question 14: Static arrays, recursion and binary search

15 marksProgramming and data structures
The question

A program has been developed for an embedded system with limited data storage capacity, so execution time and memory usage must be planned precisely. The static integer array A holds 9, 8, 7, 4, 1, 2, 1, 3 at indexes 0 to 7. The recursive sub-program rec(M, A) is shown.

rec (M, A)
    if M >= 3
        then return A[M] * rec(M-1, A)
        else return 1
    end if
end rec

(a) Outline two disadvantages of using a dynamic data structure in this program. [4]

(b) Determine the value of rec(7, A). Show all your working. [5]

(c) Construct an algorithm in pseudocode for the sub-program isThere(X, ARR), which uses an iterative binary search on ARR (8 integers sorted in ascending order) and returns TRUE if X is in ARR, otherwise FALSE. [6]

The static integer array A with indexes 0 to 7 holding 9, 8, 7, 4, 1, 2, 1, 3. rec(7, A) multiplies the values at indexes 3 to 7.[0][1][2][3][4][5][6][7]98741213multiplied by rec(7, A)
Array A. rec(7, A) multiplies A[3] to A[7]: 4 × 1 × 2 × 1 × 3 = 24.

(a)[4 marks]

  1. A dynamic structure grows and shrinks while the program runs, allocating memory as needed.
  2. Memory use is unpredictable: the structure may grow until the small memory of the embedded system runs out, causing a crash or overflow. Each node also needs extra memory for its pointers.
  3. Execution time is unpredictable and slower: memory is allocated at run time and elements must be reached by following pointers (sequential access), not by direct indexing.

Answer:Unpredictable memory use (it may run out of the limited memory, and pointers use extra space); slower and less predictable execution (run-time allocation and sequential access).

(b)[5 marks]

  1. The base case: when M < 3 the function returns 1. Otherwise it returns A[M] × rec(M − 1, A).
  2. rec(7) = A[7] × rec(6) = 3 × rec(6)
  3. rec(6) = A[6] × rec(5) = 1 × rec(5); rec(5) = A[5] × rec(4) = 2 × rec(4)
  4. rec(4) = A[4] × rec(3) = 1 × rec(3); rec(3) = A[3] × rec(2) = 4 × rec(2); rec(2) = 1 (because 2 ≥ 3 is false).
  5. Unwind: rec(3) = 4, rec(4) = 4, rec(5) = 8, rec(6) = 8, rec(7) = 3 × 8 = 24.

Answer:rec(7, A) = 24

Watch out: It multiplies A[3] to A[7]: 4 × 1 × 2 × 1 × 3 = 24.

(c)[6 marks]

  1. Keep two indexes, LOW and HIGH, marking the part of the array still to search.
  2. Each pass looks at the middle element. If it equals X we have found it. If X is larger, search the upper half; if smaller, search the lower half.
  3. Stop when the item is found or when LOW passes HIGH (the part to search is empty).
isThere(X, ARR)
    LOW = 0
    HIGH = 7
    FOUND = FALSE
    loop while LOW <= HIGH and FOUND = FALSE
        MID = (LOW + HIGH) div 2
        if ARR[MID] = X then
            FOUND = TRUE
        else if ARR[MID] < X then
            LOW = MID + 1
        else
            HIGH = MID - 1
        end if
    end loop
    return FOUND
end isThere

Answer:An iterative binary search that halves the search range until X is found (TRUE) or the range is empty (FALSE), as in the pseudocode.

Paper 1, Question 15: Two-dimensional arrays: concert tickets

15 marksProgramming and data structures
The question

A music college has a 200-seat concert hall with 20 rows of 10 seats. Ticket types: A (general admission) 15, B (faculty, staff, alumni, senior citizens) 10, C (students) 5. The static two-dimensional char array CONCERT[20][10] stores A, B or C for the ticket type sold for each seat, or X if no ticket was sold. For example, CONCERT[19][0] = ‘C’.

(a) Outline two reasons why a static two-dimensional char array is a suitable data structure to hold this data. [4]

(b) Construct an algorithm in pseudocode for student(CONCERT, ROW), which outputs the number of student tickets sold in that row. [4]

(c) Construct an algorithm in pseudocode for revenue(CONCERT), which outputs the total amount of money from the sale of tickets for a concert. [7]

Excerpt from the two-dimensional char array CONCERT with rows 0, 1, 2 and 19 and seats 0 to 9. Row 0: A A A C B B A C C A. Row 1: X X A A C C A A A B. Row 2: A C C C C C A A B X. Row 19: C X X X B B B X A X.[0][1][2][3][4][5][6][7][8][9][0]AAACBBACCA[1]XXAACCAAAB[2]ACCCCCAABX……[19]CXXXBBBXAX
An excerpt from CONCERT. Row 0 has 3 student tickets (C) and row 1 has 2.

(a)[4 marks]

  1. The hall always has exactly 20 rows of 10 seats, so the size is known in advance and never changes. A static array of fixed size fits, with no wasted or extra memory.
  2. The two indexes match the layout of the hall (row and seat), so any seat can be accessed directly as CONCERT[row][seat]. Each seat needs only one character.

Answer:The number of seats is fixed (20 × 10), so a static size is ideal; the row and column indexes map directly to seats, giving direct access, and a single char per seat is enough.

(b)[4 marks]

  1. Loop through the 10 seats in the given row and count the ‘C’ characters.
student(CONCERT, ROW)
    COUNT = 0
    loop SEAT from 0 to 9
        if CONCERT[ROW][SEAT] = 'C' then
            COUNT = COUNT + 1
        end if
    end loop
    output COUNT
end student

Answer:Count the C entries in row ROW and output the count.

(c)[7 marks]

  1. Use nested loops to visit every seat: rows 0 to 19 and seats 0 to 9.
  2. Add 15, 10 or 5 for A, B or C. An X adds nothing.
  3. Output the total after both loops.
revenue(CONCERT)
    TOTAL = 0
    loop ROW from 0 to 19
        loop SEAT from 0 to 9
            if CONCERT[ROW][SEAT] = 'A' then
                TOTAL = TOTAL + 15
            else if CONCERT[ROW][SEAT] = 'B' then
                TOTAL = TOTAL + 10
            else if CONCERT[ROW][SEAT] = 'C' then
                TOTAL = TOTAL + 5
            end if
        end loop
    end loop
    output TOTAL
end revenue

Answer:Nested loops over all 200 seats, adding the price for each A, B or C, then output the total.

COMPUTER SCIENCE HL · 4 MAY 2026

IB Computer Science HL May 2026 Paper 2 · Option A: worked solutions

  • 4 May 2026, morning
  • 1 hour 20 minutes
  • 65 marks
  • Paper code 2226-4429

Option A, databases (questions 1 to 4).

Paper 2, Option A, Question 1: ER diagrams, timestamps, concurrency and recovery

16 marksOption A: databases
The question

A software company employs programmers and managers. Each programmer works on a single project; each project has multiple programmers; each manager oversees multiple projects; each project has one manager. When a programmer changes source code, the changes are written to a database and timestamped. Multiple programmers can work on the same code at the same time.

(a) Construct an entity-relationship diagram (ERD) that shows the relationships between programmer, manager and project. [2]

(b) Outline one benefit of using a database to track changes to source code. [2]

(c) Outline the role of timestamps in maintaining data consistency. [2]

(d) Explain one way in which concurrency can be managed in the database when two programmers update the same line of code at the same time. [5]

(e)(i) Outline what is meant by a consistent database state. [2]

(e)(ii) Describe one recovery method that can be used to restore a database. [3]

Entity-relationship diagram: MANAGER one-to-many PROJECT, and PROJECT one-to-many PROGRAMMER, drawn with crow’s-foot notation.MANAGERPROJECTPROGRAMMER1M1Moverseesworks on
One manager oversees many projects; one project has many programmers.

(a)[2 marks]

  1. Read each rule as a relationship. One project has many programmers, and each programmer has one project: PROJECT to PROGRAMMER is one-to-many.
  2. One manager oversees many projects, and each project has one manager: MANAGER to PROJECT is one-to-many.

Answer:MANAGER 1 —< many PROJECT 1 —< many PROGRAMMER (see the diagram).

(b)[2 marks]

  1. Every change is stored with who made it and when, so the history is complete and searchable.

Answer:A full, searchable history of changes: the team can see who changed what and when, and roll back to an earlier version if a change introduces a bug.

(c)[2 marks]

  1. A timestamp records exactly when each change was made.
  2. The database can then apply changes in the correct order and detect when two updates conflict (for example a later update based on old data).

Answer:Timestamps record the order of updates, so transactions are applied in sequence and conflicting or out-of-date updates can be detected and rejected.

(d)[5 marks]

  1. Locking: when programmer 1 starts to update the record holding that line, the DBMS places an exclusive (write) lock on it.
  2. While the lock is held, programmer 2’s update must wait; they cannot change the same record at the same moment.
  3. When programmer 1’s transaction commits, the lock is released and programmer 2’s transaction proceeds using the updated value.
  4. This prevents the lost-update problem, where one programmer’s change silently overwrites the other’s, so the data stays consistent.
  5. (Alternative: optimistic concurrency with timestamps, where the second update is rejected if the record changed after it was read.)

Answer:Record locking: the first transaction locks the record, the second waits until it commits and the lock is released, which prevents lost updates and keeps the data consistent.

(e)(i)[2 marks]

  1. A consistent state is one where all the data obeys the database’s rules and constraints (keys, relationships, data types), and every transaction has either completed fully or not at all.

Answer:All data satisfies the integrity rules and constraints, with no partly completed transactions.

(e)(ii)[3 marks]

  1. Restore from backup plus the transaction log (roll forward).
  2. The most recent full backup is restored first. Then the transaction log, which records every committed change since that backup, is replayed to redo those transactions.
  3. Transactions that were incomplete at the time of the failure are rolled back, so the database returns to the last consistent state.

Answer:Restore the latest backup, then replay the transaction log to redo committed transactions and undo incomplete ones, returning to the last consistent state.

Paper 2, Option A, Question 2: Primary keys, data types, SQL and 3NF

14 marksOption A: databases
The question

A manager oversees several projects, each for a specific client. PROJECT (ManagerID, ClientID, ProjectID, ProjectName, StartDate, EndDate, Priority). The PROJECT, MANAGER and CLIENT tables and a table of programmers’ professional development are shown.

(a) Suggest a primary key for the PROJECT table. [2]

(b) The Priority field stores only two values: High or Low. Outline an appropriate data type for the Priority field. [2]

(c) Construct a query to find ClientName and ContactNumber for projects managed by Sehee Choi that are High priority. [5]

(d) Construct the database in third normal form (3NF) for the entities shown in Figure 4, using the notation TABLE (Key, Field1, Field2, …). [5]

The PROJECT table (ManagerID, ClientID, ProjectID, ProjectName, StartDate, EndDate, Priority) with four projects, and the MANAGER table (M123 Sehee Choi, M456 Errol Blake, M789 Faye Yang).ManagerIDClientIDProjectIDProjectNameStartDateEndDatePriorityM123C0011AI bot2024-01-012025-12-31HighM456C0022Website2024-02-012025-08-31LowM123C0033Data analysis2024-03-012025-11-30LowM789C0044Cybersecurity2024-04-012025-09-30HighManagerIDManagerNamePhoneNumberM123Sehee Choi0107930361M456Errol Blake0105940577M789Faye Yang0109839399
PROJECT and MANAGER tables. Sehee Choi (M123) manages project 1 (High, client C001) and project 3 (Low).

(a)[2 marks]

  1. A primary key must be unique for every row and never empty.
  2. ProjectID is different for every project (1, 2, 3, 4), while ManagerID and ClientID can repeat (M123 appears twice).

Answer:ProjectID, because it uniquely identifies each project.

(b)[2 marks]

  1. Only two possible values are needed.

Answer:Boolean (for example IsHighPriority = TRUE/FALSE), because there are only two values; it uses the least storage. (A one-character text field H/L, or an enumerated type, would also work.)

(c)[5 marks]

  1. The data is in three tables, so join them: PROJECT to CLIENT on ClientID, and PROJECT to MANAGER on ManagerID.
  2. Filter on the manager’s name and the priority.
  3. Check: Sehee Choi is M123, who manages projects 1 (High, client C001) and 3 (Low). So the result is Tech Innovators, 0123456789.
SELECT CLIENT.ClientName, CLIENT.ContactNumber
FROM PROJECT
    INNER JOIN CLIENT  ON PROJECT.ClientID  = CLIENT.ClientID
    INNER JOIN MANAGER ON PROJECT.ManagerID = MANAGER.ManagerID
WHERE MANAGER.ManagerName = 'Sehee Choi'
  AND PROJECT.Priority = 'High';

Answer:Result: Tech Innovators, 0123456789.

(d)[5 marks]

  1. Find the repeated groups: Jana Jain and Kev McClure each appear twice, and qualifications such as “Azure AI engineer” appear twice.
  2. Programmer details (name, level) depend only on the programmer ID, so they go in their own table.
  3. Qualification details depend only on the qualification. The course provider (company), date, completion and cost belong to one enrolment of a programmer on a course.
  4. Remove transitive dependencies so every non-key field depends on the key, the whole key and nothing but the key.

Answer:PROGRAMMER (ProgrammerID, ProgrammerName, Level) QUALIFICATION (QualificationID, QualificationName) COMPANY (CompanyID, CompanyName) COURSE (ProgrammerID, QualificationID, CourseDate, CompanyID, Complete, Cost) — the key is the first three fields together, and ProgrammerID, QualificationID and CompanyID are foreign keys.

Watch out: Underline the primary key of every table and show the foreign keys that link them.

Paper 2, Option A, Question 3: Schemas, data dictionaries, DDL and security

15 marksOption A: databases
The question

A company is developing a database to track employees working remotely, planned with a conceptual schema and a data dictionary. Remote working needs more security. External regulators will be allowed to view the database.

(a) Outline the role of a conceptual schema. [2]

(b) Outline the purpose of a data dictionary. [2]

(c) Describe the role of a data definition language (DDL) in implementing a data model. [3]

(d) List three tasks that a database administrator carries out to ensure data security. [3]

(e) Explain the benefits of allowing external regulators to view the database. [5]

(a)[2 marks]

  1. The conceptual schema is the overall logical design of the whole database, independent of how it is physically stored.
  2. It shows all the entities, attributes and relationships, and gives designers and users a shared picture of the data.

Answer:It describes the whole database logically: all entities, attributes, relationships and constraints, independent of physical storage.

(b)[2 marks]

  1. A data dictionary is metadata: data about the data.

Answer:It stores metadata about every field and table: names, data types, sizes, validation rules, keys and relationships, so everyone uses the data consistently.

(c)[3 marks]

  1. The data model is a design; DDL turns it into real database structures.
  2. DDL commands such as CREATE TABLE, ALTER TABLE and DROP TABLE define the tables, fields, data types, primary and foreign keys and constraints.
  3. The definitions are stored in the data dictionary, so the DBMS can enforce them.

Answer:DDL statements (CREATE, ALTER, DROP) build the tables, fields, data types, keys and constraints from the model and record them in the data dictionary.

(d)[3 marks]

  1. Think about who can access the data, how it is protected and how it can be restored.

Answer:Set up user accounts and access rights (permissions/views); make and test regular backups; apply security updates and monitor access logs (also encryption, password policies).

(e)[5 marks]

  1. Transparency: regulators can check directly that the company follows employment and data protection laws, for example working hours of remote staff.
  2. Trust: independent oversight increases the confidence of employees, clients and the public.
  3. Earlier detection: problems or non-compliance can be found and corrected quickly, before they become serious, which avoids fines.
  4. Efficiency: audits are faster because regulators read the data directly instead of the company preparing reports.
  5. To keep this safe, regulators should get read-only access, through views that show only the data they need.

Answer:Regulators can verify compliance directly, which builds trust, finds problems early, avoids penalties and makes audits quicker; read-only views keep the data protected.

Paper 2, Option A, Question 4: Data warehousing and data mining

20 marksOption A: databases
The question

A company uses a multidimensional database for data mining, and an ETL process to load a data warehouse. It uses decision trees to predict programming errors, deviation detection to identify copyrighted code, and cluster analysis and classification to study coding practices.

(a) List three benefits of using a multidimensional database model for data mining. [3]

(b) Define the term data warehouse. [1]

(c) Explain the need for data transforming in the ETL process. [5]

(d) Describe how predictive modelling using decision trees can help predict programming errors. [4]

(e) Describe how deviation detection could be used to identify copyrighted code. [2]

(f) Compare cluster analysis and classification techniques in this scenario. [5]

(a)[3 marks]

  1. A multidimensional model stores data as a cube with dimensions such as time, project and programmer.

Answer:Fast analysis of large amounts of data; viewing data from several dimensions (slice and dice, drill down); easier discovery of trends and patterns (also pre-aggregated summaries).

(b)[1 mark]

  1. A warehouse brings data together for analysis, not for day-to-day transactions.

Answer:A large central store of integrated, historical data from many sources, used for analysis and decision-making.

(c)[5 marks]

  1. Data is extracted from several sources that store it in different ways.
  2. Formats differ: dates may be 2024-01-01 in one system and 01/01/24 in another; units, codes and field names also differ.
  3. The data may contain errors, duplicates or missing values.
  4. Transforming cleans the data, converts it to one consistent format, removes duplicates and may aggregate it.
  5. Without this step the warehouse would hold inconsistent data, and the analysis and data mining results would be inaccurate.

Answer:Data from different sources has different formats, errors and duplicates; transforming cleans and standardizes it so the warehouse is consistent and analysis is reliable.

(d)[4 marks]

  1. Historical data on past errors (for example the type of code, its size, the programmer’s experience and test coverage) is used to build the tree.
  2. At each node the tree splits the data on the attribute that best separates error-prone code from error-free code.
  3. Each leaf gives a predicted outcome, for example “high chance of a null-pointer error”.
  4. New code is passed down the tree to predict which errors are likely, so testing can focus there.

Answer:The tree is trained on past error data, splitting on the attributes that best separate outcomes; new code is classified down the branches to a leaf that predicts likely errors.

(e)[2 marks]

  1. The baseline shows the normal patterns of the company’s own code: style, naming, structure and comments.
  2. Code that deviates strongly from this baseline (an anomaly), or closely matches known external code, is flagged for checking as possibly copied.

Answer:New code is compared with the baseline of the company’s normal coding patterns; code that deviates sharply (or matches known outside code) is flagged as possibly copied.

(f)[5 marks]

  1. Similarity: both are data-mining techniques that group records of code or programmers to find insights about coding practices.
  2. Cluster analysis is unsupervised: there are no predefined labels. It groups code with similar features (for example length, complexity, number of bugs), which may reveal unexpected patterns such as a cluster of very complex, error-prone modules.
  3. Classification is supervised: it is trained on code that is already labelled (for example “good practice” or “needs improvement”) and then assigns new code to one of those known classes.
  4. So clustering suits exploring the data to discover new areas for improvement, while classification suits checking new code against standards the company already knows.

Answer:Both group data, but clustering is unsupervised and discovers new groups of similar code, whereas classification is supervised and sorts new code into predefined labelled classes.

COMPUTER SCIENCE HL · 4 MAY 2026

IB Computer Science HL May 2026 Paper 2 · Option B: worked solutions

  • 4 May 2026, morning
  • 1 hour 20 minutes
  • 65 marks
  • Paper code 2226-4429

Option B, modelling and simulation (questions 5 to 8). The paper lists the school B range as “69 and 84” in one place and “70–84” in Figure 9; the figure’s 70–84 is used, which avoids an overlap with grade C.

Paper 2, Option B, Question 5: Spreadsheet formulas and text functions

15 marksOption B: modelling and simulation
The question

A spreadsheet shows five students’ scores at City Walk School. Sem 1 (column B) is out of 40 and Sem 2 (column C) is out of 60. Final % (column D) weights semester 1 by 25% and semester 2 by 75%. The school’s grade boundaries are stored in H2:I6 (35 E, 47 D, 60 C, 70 B, 85 A).

(a)(i) State Elaine Anaya Khan’s percentage for semester 1. [1]

(a)(ii) Construct the formula to calculate the percentage for cell D2. [2]

(b) Construct a formula to automatically add Elaine Anaya Khan’s grade (shown in column I) to cell E2. [3]

(c) The formula =FIND(A2," ") is in F2 and copied down. Outline why cell F4 produced an error. [2]

(d) =ISNUMBER(value) returns TRUE if the value is a number. F2 should be 7 and F4 should be FALSE. Construct a formula for cell F4 as described. [3]

(e) Explain how a last name could be extracted while ignoring a middle name. [4]

Spreadsheet: student name, Sem 1 out of 40, Sem 2 out of 60 and Final %. Elaine Anaya Khan 20, 30, 50.0; Angel Chanchikova 32, 54, 87.5; Isabella 26, 45, 72.5; Sarah Naveneethan 32, 38, 67.5; Scott Abou Khalil 16, 24, 40.0. Grade table H2:I6: 35 E, 47 D, 60 C, 70 B, 85 A.A: Student nameB: Sem 1C: Sem 2D: Final %2Elaine Anaya Khan203050.03Angel Chanchikova325487.54Isabella264572.55Sarah Naveneethan323867.56Scott Abou Khalil162440.0H: scoreI: grade35E47D60C70B85A
The scores and the grade lookup table in H2:I6.

(a)(i)[1 mark]

  1. Elaine scored 20 out of 40: 2040×100=50%.

Answer:50%

(a)(ii)[2 marks]

  1. Convert each semester to a fraction of its total, then weight it.
  2. Check with Elaine: 2040×25+3060×75=12.5+37.5=50.0 ✓.

Answer:=(B2/40)*25+(C2/60)*75

(b)[3 marks]

  1. The boundaries in H2:H6 are in ascending order, so an approximate-match lookup finds the largest boundary that is not more than the score.
  2. Use absolute references ($) so the formula can be copied down.
  3. Elaine: 50.0 → the largest boundary not above 50 is 47 → D.

Answer:=VLOOKUP(D2,H2:I6,2,TRUE) (gives D for Elaine)

Watch out: Use TRUE (approximate match), not FALSE, because 50.0 is not exactly in the table.

(c)[2 marks]

  1. FIND looks for a space in the name. “Isabella” has no space, because no last name was entered.
  2. When FIND cannot find the text it returns the #VALUE! error.

Answer:Isabella has only one name with no space, so FIND cannot find " " and returns #VALUE!.

(d)[3 marks]

  1. Test whether FIND gives a number. If it does, show it; if not, show FALSE.
=IF(ISNUMBER(FIND(" ",A4)), FIND(" ",A4), FALSE)

Answer:=IF(ISNUMBER(FIND(" ",A4)),FIND(" ",A4),FALSE)

(e)[4 marks]

  1. The last name is the text after the last space, so we must find the last space, not the first.
  2. One way: count the spaces with LEN(A2)−LEN(SUBSTITUTE(A2," ","")), then use SUBSTITUTE to replace only that last space with a marker character such as "#".
  3. FIND("#",…) now gives the position of the last space. RIGHT (or MID) then returns everything after it.
  4. For “Elaine Anaya Khan” the last space is at position 13, so the result is “Khan” and the middle name “Anaya” is ignored.
=RIGHT(A2, LEN(A2) - FIND("#", SUBSTITUTE(A2, " ", "#",
       LEN(A2) - LEN(SUBSTITUTE(A2, " ", "")))))

Answer:Find the position of the last space (replace the last space with a marker using SUBSTITUTE, then FIND it) and take the text to its right.

Paper 2, Option B, Question 6: Scaling scores to another range

12 marksOption B: modelling and simulation
The question

School score ranges: E 35–46, D 47–59, C 60–69, B 70–84, A 85–100. Ministry ranges: E 40–51, D 52–65, C 66–75, B 76–90, A 91–100. The formula KS=(SSS−MinSSMaxSS−MinSS)×(91−40)+40 scales a school score (MinSS = 35, MaxSS = 85) to the Ministry range. STUDENTS = [Khan, Chanchikova, Hodroge, Naveneethan, Khalil]; SCORES = [50, 88, 73, 68, 40]; MINISTRY = [0, 0, 0, 0, 0].

(a) Calculate KS to one decimal place, where SSS = 60. You must show your working. [2]

(b) Construct an algorithm in pseudocode that takes each value in SCORES, applies the formula, rounds the result to the nearest integer and stores it in MINISTRY. [3]

(c) The portal allows only integers between 40 and 100. Describe one other automated check the Ministry might use to ensure the data is accurate. [3]

(d) Grade A is 91 to 100. Construct an algorithm in pseudocode that counts the number of grade A students and stores the result as a percentage of the total number of students. [4]

(a)[2 marks]

  1. KS=60−3585−35×(91−40)+40=2550×51+40.
  2. =0.5×51+40=25.5+40=65.5.

Answer:KS=65.5

(b)[3 marks]

  1. Loop through all five positions. Apply the formula to each score and round it.
loop I from 0 to 4
    KS = ((SCORES[I] - 35) / (85 - 35)) * (91 - 40) + 40
    MINISTRY[I] = round(KS)
end loop

Answer:Loop over the indexes, compute the scaled score with the formula, round it and store it in MINISTRY at the same index.

(c)[3 marks]

  1. The portal already does a type check (integer) and a range check (40 to 100).
  2. Presence check: every student name and score must be filled in; empty fields are rejected.
  3. (Others: a format check that the student ID matches a set pattern; a lookup check that the student is in the school’s register; a duplicate check so a student is not uploaded twice.)

Answer:A presence check: the system rejects an upload if any required field (name or score) is empty, asking the school to complete it (or a duplicate/lookup check).

(d)[4 marks]

  1. Count the scores in the MINISTRY array that are between 91 and 100.
  2. Divide by the number of students (5) and multiply by 100.
COUNT = 0
loop I from 0 to 4
    if MINISTRY[I] >= 91 and MINISTRY[I] <= 100 then
        COUNT = COUNT + 1
    end if
end loop
PERCENT = COUNT / 5 * 100

Answer:Count the A grades and convert to a percentage of all students.

Paper 2, Option B, Question 7: Real-time simulation of attendance

18 marksOption B: modelling and simulation
The question

The Ministry of Education is developing a real-time simulation to analyse the impact of student attendance on academic performance across all schools. City Walk School is used as a test case. A heat map shows absences against grades for schools in the region.

(a) Outline what is meant by real-time simulation. [2]

(b) Student attendance rate is one variable. Identify three other variables that would be required to model this simulation effectively. [3]

(c) Outline two categories of hardware needed for this simulation. [4]

(d) Discuss one factor that could be used to judge the effectiveness of this test case for assessing the accuracy of the simulation model. [5]

(e) Outline two factors that would affect the memory needs of a 2D visualization such as the heat map. [4]

Heat map of grade against number of absences. Most points with fewer than 18 absences have grades between 50 and 90; students with 24 or more absences have much lower grades (30, 10 and 0).gradeabsences061218243036020406080100
Heat map (redrawn from the printed figure). Darker dots mean more students. Grades fall sharply above about 20 absences.

(a)[2 marks]

  1. A real-time simulation runs at the same rate as the real system and uses live data as it arrives.

Answer:A simulation that runs at the same speed as the real world, continuously updated with live data so results reflect the current situation.

(b)[3 marks]

  1. Think about what else affects academic performance.

Answer:Students’ test scores (grades); lateness or punctuality; study hours or homework completion (also socio-economic background, class size, subject).

(c)[4 marks]

  1. Processing: powerful servers (or cloud computing) to run the model on data from every school in real time.
  2. Input/data collection: devices in schools such as electronic registration systems or ID card readers that send attendance data continuously.
  3. (Also storage: large databases for historical data; output: displays for the visualizations.)

Answer:High-performance servers to process the model in real time, and input devices (electronic registers, card readers) to collect attendance data continuously.

(d)[5 marks]

  1. Factor: how representative City Walk School is of all the schools in the region.
  2. If its students are similar in size, background and attendance patterns to other schools, the predictions that match its actual results give good evidence that the model will work everywhere.
  3. But one school is a small sample. If it is unusual (for example its grade boundaries are lower than the Ministry’s), a model that is accurate there may not be accurate for other schools.
  4. So the test case is effective only if the school is typical, or if results are confirmed with more schools before the model is used regionally.

Answer:Representativeness: an accurate prediction at City Walk shows the model works only if the school is typical of the region; because it is a single, possibly unusual school, further testing is needed.

(e)[4 marks]

  1. The number of data points: every student record from every school must be stored and plotted, so more schools and students need more memory.
  2. The resolution and colour depth of the image: more pixels and more bits per pixel (for the colour shading) take more memory.
  3. (Also: how often the map is refreshed with real-time data.)

Answer:The number of data points plotted (students and schools) and the resolution and colour depth of the rendered image.

Paper 2, Option B, Question 8: Genetic algorithms, chatbots and natural language

20 marksOption B: modelling and simulation
The question

The Ministry uses a genetic algorithm to find the best locations for new schools, a chatbot on its website, a neural network for natural language processing of handwritten essays, and an educational tool based on how humans learn languages.

(a) Outline two steps, other than those already stated (initial population; iterate until a stopping condition), that must be taken for the genetic algorithm to find the most suitable locations. [4]

(b)(i) Outline one advantage of using a chatbot. [2]

(b)(ii) Outline one disadvantage of using a chatbot. [2]

(c) Identify two key structures of natural language. [2]

(d) Evaluate the effectiveness of natural language processing for analysing student essays. [4]

(e) Explain two principles of language learning that should be applied in this educational tool. [6]

(a)[4 marks]

  1. Fitness evaluation: each candidate location is scored with a fitness function, for example how many students live nearby, travel distance and land cost.
  2. Selection, crossover and mutation: the fittest locations are selected as parents; crossover combines parts of two solutions and mutation makes small random changes, producing a new generation.

Answer:Evaluate each candidate with a fitness function; select the fittest and breed a new generation by crossover and mutation.

(b)(i)[2 marks]

  1. A chatbot answers automatically.

Answer:It is available 24 hours a day and answers many schools at once instantly, reducing staff workload.

(b)(ii)[2 marks]

  1. A chatbot only understands what it was trained on.

Answer:It may misunderstand complex or unusual questions and give wrong or unhelpful answers, so users still need a human.

(c)[2 marks]

  1. Language has structure at several levels.

Answer:Syntax (grammar and sentence structure) and semantics (meaning); also morphology, pragmatics, phonology.

(d)[4 marks]

  1. Strengths: NLP can process large volumes of essays quickly and consistently, checking grammar, vocabulary and structure, and spotting patterns across the whole region.
  2. Weaknesses: handwriting recognition errors pass into the analysis; NLP struggles with ambiguity, creativity, irony and the deeper quality of an argument; its judgement depends on the training data, which may be biased.
  3. Conclusion: NLP is effective for large-scale, surface-level analysis and for flagging essays, but human markers are still needed to judge meaning and originality.

Answer:Fast and consistent for large volumes and surface features, but limited by handwriting errors, ambiguity and bias, so it should support, not replace, human markers.

(e)[6 marks]

  1. Principle 1: spaced repetition. Research shows people remember words better when they meet them again at increasing intervals, just before they would forget. The tool should schedule reviews of vocabulary at growing intervals, adapted to each student’s mistakes.
  2. This moves words from short-term to long-term memory and avoids wasting time on words the student already knows.
  3. Principle 2: learning in context with immediate feedback (comprehensible input). Humans acquire language best from meaningful sentences and conversations slightly above their current level, not from isolated word lists.
  4. The tool should present words in realistic dialogues, let students practise using them, and give immediate, specific corrections, so errors are fixed before they become habits.

Answer:Spaced repetition (review items at increasing intervals to build long-term memory) and contextual, interactive practice with immediate feedback (meaningful input just above the learner’s level).

COMPUTER SCIENCE HL · 4 MAY 2026

IB Computer Science HL May 2026 Paper 2 · Option C: worked solutions

  • 4 May 2026, morning
  • 1 hour 20 minutes
  • 65 marks
  • Paper code 2226-4429

Option C, web science (questions 9 to 13).

Paper 2, Option C, Question 9: URLs, browsers, protocols, XML and XSLT

14 marksOption C: web science
The question

Callum enters the URL https://www.ibo.org in a web browser. A web page lists the students in a class using Class.xml and Class_style.xsl.

<!-- Class.xml -->
<?xml-stylesheet type="text/xsl" href="class_style.xsl"?>
<class>
    <student>
        <firstname>John</firstname>
        <surname>Doe</surname>
        <classname>Mathematics</classname>
    </student>
    ...
</class>

<!-- Class_style.xsl (inside the template) -->
<xsl:for-each select="class/student">
    <tr>
        <td><xsl:value-of select="firstname"/></td>
        <td><xsl:value-of select="surname"/></td>
        <td><xsl:value-of select="classname"/></td>
    </tr>
</xsl:for-each>

(a) State two characteristics of a URL. [2]

(b) Outline two functions of a web browser. [2]

(c) HTTPS is an example of a protocol. Explain why protocols are important. [3]

(d) Identify two characteristics of extensible mark-up language (XML). [2]

(e) With reference to Class.xml and Class_style.xsl, describe how a page connects to the underlying data source. [2]

(f) Identify three characteristics of transmission control protocol (TCP). [3]

(a)[2 marks]

  1. A URL is the address of a resource on the web.

Answer:It is unique to a resource; it contains the protocol (https), the domain name (www.ibo.org) and optionally a path to a file.

(b)[2 marks]

  1. A browser is client software for the web.

Answer:It sends requests to web servers using HTTP/HTTPS and receives the responses; it renders HTML, CSS and scripts into a page the user can view (also bookmarks, history, caching).

(c)[3 marks]

  1. Devices from different manufacturers, running different software, must exchange data.
  2. A protocol is an agreed set of rules for the format, order and error checking of messages, so both sides understand each other.
  3. HTTPS also adds rules for encryption, so data such as passwords is transferred securely.

Answer:Protocols are shared rules that let different devices and software communicate reliably; HTTPS adds encryption so the data is secure.

(d)[2 marks]

  1. XML describes data, not how it looks.

Answer:Users define their own tags (it is extensible); it is a hierarchical, self-describing and human- and machine-readable text format (also strict well-formed rules).

(e)[2 marks]

  1. The first line of Class.xml is a processing instruction that links it to the stylesheet class_style.xsl.
  2. The XSLT template matches the root, loops over each class/student with xsl:for-each and uses xsl:value-of to put firstname, surname and classname into the rows of an HTML table, which the browser displays.

Answer:Class.xml links to Class_style.xsl, which transforms the XML: it loops through each student and inserts the firstname, surname and classname values into an HTML table.

(f)[3 marks]

  1. TCP sits in the transport layer.

Answer:Connection-oriented (a three-way handshake); reliable delivery with acknowledgements and retransmission; data is delivered in the correct order (also flow and congestion control, error checking).

Paper 2, Option C, Question 10: Deep web, web crawling and SEO

15 marksOption C: web science
The question

It is estimated that the deep web is 500 times larger than the surface web. Developers try to make their sites rank higher in search engine results.

(a) Outline one difference between the deep web and the surface web. [2]

(b) Define the term web crawler. [1]

(c) Outline the web crawling process. [3]

(d) Describe two advantages of parallel web crawling. [4]

(e) Evaluate two white hat techniques that may be used in search engine optimization. [5]

(a)[2 marks]

  1. The difference is whether search engines can index the pages.

Answer:The surface web is indexed by search engines and found by searching, while the deep web is not indexed (for example pages behind logins, forms or databases).

(b)[1 mark]

  1. Also called a spider or bot.

Answer:A program that automatically visits web pages and follows their links to collect and index content for a search engine.

(c)[3 marks]

  1. The crawler starts with a list of seed URLs.
  2. It downloads each page, stores or indexes its content and metadata, and extracts all the hyperlinks.
  3. New links are added to the queue (frontier) of URLs to visit, and the process repeats, respecting robots.txt and avoiding pages it has already visited.

Answer:Start from seed URLs; fetch and index each page; extract its links and add new ones to the queue; repeat, following robots.txt.

(d)[4 marks]

  1. Speed: several crawler processes fetch different pages at the same time, so a much larger part of the web is covered in the same time.
  2. Freshness: because pages are revisited more often, the index stays more up to date.
  3. (Also: load can be spread geographically, so crawlers close to servers reduce network delays; if one crawler fails, others continue.)

Answer:Many pages are downloaded at the same time, so coverage is larger and faster; the index can be refreshed more often (and the load is spread across locations).

(e)[5 marks]

  1. Technique 1: high-quality, relevant content with appropriate keywords in titles, headings and text. Benefit: it matches what users search for and keeps visitors on the site, which search engines reward over the long term. Drawback: it takes time and effort, and results are slow to appear.
  2. Technique 2: earning quality backlinks from reputable sites (for example by producing useful resources others link to). Benefit: links are a strong ranking signal for algorithms such as PageRank. Drawback: links depend on other site owners and are hard to obtain quickly.
  3. Conclusion: both techniques follow search engine guidelines, so they bring lasting rankings with no risk of penalties, unlike black hat methods, even though they are slower.

Answer:Quality keyword-relevant content and earning reputable backlinks both improve rankings sustainably within the guidelines, but they take time and effort; still better than risky black hat techniques.

Paper 2, Option C, Question 11: Ubiquitous computing and distributed social networks

16 marksOption C: web science
The question

Violet is a photographer with profiles on several social media platforms. Her platform is a community of independent sites connected by open standards such as ActivityPub: a distributed social network.

(a) Distinguish between ubiquitous computing and mobile computing. [4]

(b) Describe how open standards support interoperability. [2]

(c) Explain how distributed social networks support decentralization of the web. [6]

(d) Discuss the challenges faced by distributed social networks with reference to intellectual property. [4]

(a)[4 marks]

  1. Mobile computing: a person carries a portable device (phone, laptop, tablet) and uses it while moving, through wireless networks. The user deliberately interacts with the device.
  2. Ubiquitous (pervasive) computing: computing is embedded everywhere in the environment, in everyday objects and sensors that communicate with each other, often without the user noticing (for example smart homes, IoT).

Answer:Mobile computing is using a portable device on the move; ubiquitous computing embeds many interconnected devices in the environment so computing is everywhere and often invisible.

(b)[2 marks]

  1. An open standard such as ActivityPub is published and free for anyone to implement.
  2. Different software from different developers that follows it can exchange posts, follows and likes, so users on one server can interact with users on another.

Answer:Because the specification is public and shared, different platforms implement the same rules and can exchange data and work together.

(c)[6 marks]

  1. In a centralized network one company owns all the servers, data and rules.
  2. In a distributed network many independent servers (instances) are run by different people or organizations, and they communicate through an open protocol.
  3. No single organization controls the whole network: if one server shuts down or changes its rules, users can move to another and still reach their followers.
  4. Users can choose a server whose rules and moderation they prefer, or run their own, so they keep control of their data, such as Violet’s photos.
  5. Power and data are spread across many owners instead of concentrated in one, which is decentralization.
  6. It is also harder to censor or take down the whole network, because there is no single point of failure.

Answer:Many independently run servers linked by open protocols mean no single owner controls the data, rules or access; users choose or run their own server, and there is no single point of failure.

(d)[4 marks]

  1. When Violet posts a photo it is copied to many servers run by different owners in different countries.
  2. There is no central authority to enforce copyright: a takedown request must be sent to every server that holds a copy, and some may ignore it or be in countries with different laws.
  3. Each server has its own terms of service, so the licence under which content is shared may be unclear.
  4. Some mitigation is possible: licences such as Creative Commons in posts, watermarks, and server rules that ban copyright infringement. But protecting intellectual property remains harder than on a centralized platform.

Answer:Content is copied across many independently owned servers under different rules and laws, with no central authority, so enforcing copyright and takedowns is difficult; licences and watermarks help only partly.

Paper 2, Option C, Question 12: Weighted directed graphs and PageRank

10 marksOption C: web science
The question

A subgraph represents part of the web with weighted nodes (activity level) and weighted edges: A(3), B(5), C(9), D(4), E(5), F(2), G(1). Edges: A→D 3, A→B 2, B→D 2, D→B 4, B→C 6, C→B 2, C→D 6, D→C 2, D→F 3, D→E 2, C→E 3, E→C 5, F→E 1, E→F 1, F→G 1, E→G 2.

(a) Outline why the figure is best described as a weighted and directed graph. [2]

(b) Explain why some nodes are described as weakly connected and some as strongly connected. [4]

(c) Explain which three nodes would rank highest using the PageRank algorithm. [4]

Weighted directed graph of web pages: nodes A(3), B(5), C(9), D(4), E(5), F(2), G(1) with weighted arrows between them. A has only outgoing links and G only incoming links. B, C, D, E and F can all reach each other.3224626232351112A(3)B(5)C(9)D(4)E(5)F(2)G(1)
The subgraph. Green nodes form the strongly connected group; A (no incoming links) and G (no outgoing links) are only weakly connected.

(a)[2 marks]

  1. Weighted: every node and every edge has a number (activity level or link weight).
  2. Directed: the edges have arrows, so a link from one page to another does not mean there is a link back.

Answer:The nodes and edges carry numerical weights, and each edge has a direction (a one-way hyperlink).

(b)[4 marks]

  1. Strongly connected: every node in the group can reach every other node by following the arrows. B, C, D, E and F form such a group (for example D→F→E→C→B→D).
  2. Weakly connected: the node is joined to the graph only if the arrow directions are ignored.
  3. A has only outgoing edges (nothing points to A), so no node can reach A. G has only incoming edges, so G cannot reach any node.
  4. So A and G are only weakly connected to the rest of the graph.

Answer:B, C, D, E and F can all reach each other along the arrows (strongly connected); A has no incoming links and G no outgoing links, so they are connected only when direction is ignored (weakly connected).

(c)[4 marks]

  1. PageRank gives a page a high score when many pages, especially highly ranked ones, link to it.
  2. C has incoming links from B, D and E, with strong weights (6, 2, 5), and those pages are well linked themselves.
  3. D has incoming links from A, B and C (C→D has weight 6). E has incoming links from D, C and F.
  4. A has no incoming links and G’s rank comes only from F and E; B and F have fewer or weaker incoming links.

Answer:C, D and E: each receives several links from other well-connected (highly ranked) nodes, which PageRank rewards.

Watch out: PageRank depends on incoming links, not outgoing ones.

Paper 2, Option C, Question 13: Ambient intelligence and the IoT

10 marksOption C: web science
The question

An IoT-enabled weather station network collects, analyses and transmits weather data in real time, which represents ambient intelligence. The map shows 13 stations in a town. Stations in people’s homes use meta-tags to describe and categorize data, which is not considered an ontology.

(a) Describe one difference between ambient intelligence and collective intelligence. [2]

(b) Discuss one benefit and one limitation of IoT-enabled weather stations providing accurate weather data. [6]

(c) Outline why this metadata is not considered an ontology. [2]

(a)[2 marks]

  1. Ambient intelligence: devices and sensors embedded in the environment react to people and conditions automatically, like the weather stations.
  2. Collective intelligence: knowledge that emerges when many people contribute and cooperate, for example Wikipedia.

Answer:Ambient intelligence comes from smart devices embedded in the environment acting automatically; collective intelligence comes from many people combining their knowledge.

(b)[6 marks]

  1. Benefit: with 13 stations spread across the town, data is collected at many points continuously and in real time.
  2. This gives a detailed local picture (for example a sudden storm in one area) that a single official station would miss, so warnings can be issued quickly and accurately.
  3. Limitation: many stations are in people’s homes, so they are not professionally sited or maintained. A sensor in direct sun or near a wall gives wrong readings, and cheap sensors drift over time.
  4. The map also shows that stations are clustered in some areas and absent in others, so coverage is uneven.
  5. Conclusion: the network greatly improves the detail and speed of local data, but readings must be quality-checked (for example by comparing nearby stations) before being trusted.

Answer:Benefit: dense, real-time coverage gives detailed local data and fast warnings. Limitation: home stations may be badly placed, uncalibrated or unevenly spread, so accuracy varies and data needs checking.

(c)[2 marks]

  1. Meta-tags are just labels (keywords) that users choose freely, with no agreed meaning.
  2. An ontology is a formal, shared model that defines concepts and the relationships between them, so machines can reason with them.

Answer:Meta-tags are informal, user-chosen labels; an ontology is a formal shared vocabulary that defines concepts and their relationships, which the tags do not do.

COMPUTER SCIENCE HL · 4 MAY 2026

IB Computer Science HL May 2026 Paper 2 · Option D: worked solutions

  • 4 May 2026, morning
  • 1 hour 20 minutes
  • 65 marks
  • Paper code 2226-4429

Option D, object-oriented programming (questions 14 to 18). The class listings are shortened to the parts that the questions use.

Paper 2, Option D, Question 14: Classes, objects, overloading and getCost()

15 marksOption D: object-oriented programming
The question

A car rental company uses object-oriented programming to manage rentals. Each time a car is rented an instance of the Rental class (outline below) is created. It uses a class RentDate to store dates.

public class Rental
{
    private int customerID;
    private boolean priority;
    private int carID;
    private double costPerDay;
    private RentDate startDate;
    private RentDate endDate;

    public Rental(int customerID, boolean priority, int carID,
                  double costPerDay, RentDate startDate, RentDate endDate) { ... }
    public Rental(int customerID, int carID, double costPerDay,
                  RentDate startDate, RentDate endDate)   // sets priority = false

    public int getCustomerID()  { return customerID; }
    public boolean getPriority() { return priority; }
    public int getCarID()       { return carID; }
    public double getCostPerDay() { return costPerDay; }
    public RentDate getStartDate() { return startDate; }
    public RentDate getEndDate()   { return endDate; }

    public int getDays()      // returns the number of days between start and end date
    public int compareTo(RentDate thisDate) // -1 earlier, 0 same, 1 later
    public double getCost()   { // code missing }
    public String toString()  { return "Customer ID" + customerID + ... + costPerDay; }
}

(a) Describe, using the Rental class as an example, the difference between a class and an instance of a class. [3]

(b)(i) Outline why having multiple constructors in the Rental class is not a problem when creating a new Rental object. [3]

(b)(ii) State the OOP concept that allows two methods in the same class to share the same name but have different parameters. [1]

(c) Outline one benefit of creating the RentDate class to store the dates of car rentals. [2]

(d) Outline the purpose of the toString() method in the Rental class. [2]

(e) The total cost of a rental is the number of days multiplied by the cost per day. Construct the code for the getCost() method. [4]

(a)[3 marks]

  1. A class is a template (blueprint). Rental defines which attributes every rental has (customerID, priority, carID, costPerDay, startDate, endDate) and which methods it offers, but holds no actual values.
  2. An instance (object) is one specific rental created from that template with new, for example new Rental(2920393, true, 2934, 54.0, …). It has its own values stored in memory.
  3. Many instances can be created from one class, one for each car that is rented.

Answer:The class Rental is the blueprint that defines the attributes and methods; an instance is a particular rental object created with new, holding its own values (for example customer 2920393 renting car 2934).

(b)(i)[3 marks]

  1. The two constructors have the same name but different parameter lists: one takes six parameters (including priority) and one takes five.
  2. When new Rental(...) is called, the compiler chooses the constructor whose number and types of arguments match the call.
  3. So there is never any ambiguity. The five-parameter version simply sets priority to false by default.

Answer:The constructors have different parameter lists (signatures), so the compiler picks the one that matches the arguments given; the 5-parameter one sets priority to false.

(b)(ii)[1 mark]

  1. Same name, different parameter lists, same class.

Answer:Overloading (a form of polymorphism).

(c)[2 marks]

  1. RentDate encapsulates the day, month and year together with the methods that work on dates, such as compareTo() and the day difference used by getDays().
  2. The date logic is written and tested once and reused everywhere (for start and end dates, and in other classes), which reduces errors.

Answer:Encapsulation and reuse: all date data and date operations (such as compareTo) are in one tested class that every rental can reuse.

(d)[2 marks]

  1. toString() returns a String that describes the state of a Rental object: the customer ID, priority status, car and cost per day.
  2. It is used to display or print a rental in a readable form, for example in reports or when debugging, and it overrides the default toString() that only shows a memory reference.

Answer:It returns a readable String of the rental’s details so that the object can be printed or displayed.

(e)[4 marks]

  1. Use the existing method getDays() to get the number of days.
  2. Multiply by the attribute costPerDay and return the result as a double.
public double getCost()
{
    int days = this.getDays();
    double total = days * costPerDay;
    return total;
}

Answer:Return getDays() multiplied by costPerDay.

Paper 2, Option D, Question 15: Encapsulation, protected access and arrays of objects

15 marksOption D: object-oriented programming
The question

The RentalShop class stores information about the shop (location) to which the rental cars belong.

public class RentalShop {
    private String location;
    private Rental theRentals [];
    private int noOfRentals;

    public RentalShop(String location) {
        this.location = location;
        this.noOfRentals = 0;
        this.theRentals = new Rental[500];
    }
    public String getLocation()     { return location; }
    public Rental getRental(int x)  { return theRentals[x]; }
    public int getNoOfRentals()     { return noOfRentals; }

    protected void addRental(Rental newRental) {
        theRentals[noOfRentals] = newRental;
        noOfRentals = noOfRentals + 1;
    }
    protected Rental [] getTodaysRentals(RentDate today) {
        // code missing
    }
}

(a) The company would like to open a new shop in Beach Side. Construct the code required to create this instance of the RentalShop class. [3]

(b) Describe the use of the modifier protected, with reference to methods in the RentalShop class. [2]

(c) Construct the method getTodaysRentals(RentDate today), which returns an array of all the rentals starting on that day. [6]

(d) The company would like to store information about customers in a separate class. Outline two changes that would need to be made to the existing classes to accommodate this. [4]

(a)[3 marks]

  1. Declare a variable of type RentalShop and create the object with new, passing the location to the constructor.
RentalShop beachSide = new RentalShop("Beach Side");

Answer:RentalShop beachSide = new RentalShop("Beach Side");

(b)[2 marks]

  1. A protected method can be used inside its own class and by subclasses (and, in Java, by classes in the same package), but not by unrelated classes elsewhere.
  2. So addRental() and getTodaysRentals() can be called by RentalShop and by any subclass (for example a specialised airport shop), while other classes outside cannot add rentals directly. This protects the integrity of the theRentals array.

Answer:protected limits access to the class itself and its subclasses (and the package), so addRental and getTodaysRentals cannot be called by unrelated classes.

(c)[6 marks]

  1. First count how many rentals start today, so the returned array has the right size.
  2. A rental starts today when getStartDate().compareTo(today) returns 0.
  3. Then create an array of that size and copy the matching rentals into it, and return it.
protected Rental[] getTodaysRentals(RentDate today)
{
    int count = 0;
    for (int i = 0; i < noOfRentals; i++)
    {
        if (theRentals[i].getStartDate().compareTo(today) == 0)
        {
            count = count + 1;
        }
    }
    Rental[] todays = new Rental[count];
    int j = 0;
    for (int i = 0; i < noOfRentals; i++)
    {
        if (theRentals[i].getStartDate().compareTo(today) == 0)
        {
            todays[j] = theRentals[i];
            j = j + 1;
        }
    }
    return todays;
}

Answer:Count the rentals whose start date compares equal to today, create an array of that size, copy them in and return it.

Watch out: Loop only up to noOfRentals, not to 500, or you will meet null elements.

(d)[4 marks]

  1. Rental currently stores only an int customerID. It would instead hold a reference to a Customer object (an aggregation, “has-a” relationship), so the attribute, both constructors and getCustomerID() would change (for example to getCustomer()).
  2. toString() and any code that uses the customer ID would have to be updated to get details from the Customer object. RentalShop (or another class) would also need a structure to store and look up Customer objects.

Answer:Replace the int customerID in Rental with a Customer object reference (updating the constructors, accessors and toString); add a collection of Customer objects (for example in RentalShop) so customers can be stored and found.

Paper 2, Option D, Question 16: Testing, ethics, getTotalIncome() and dependencies

15 marksOption D: object-oriented programming
The question

The full solution is being tested using the following code.

RentalShop[] shops = new RentalShop[3];
shops[0] = new RentalShop("Silverlake");
shops[1] = new RentalShop("Fjord View");
shops[2] = new RentalShop("Sea View");
shops[0].addRental(new Rental(2920393, true, 2934, 54.0,
    new RentDate(2026, 2, 12), new RentDate(2026, 2, 22)));
shops[0].addRental(new Rental(2929202, 2944, 64.0,
    new RentDate(2026, 2, 14), new RentDate(2026, 2, 23)));
shops[2].addRental(new Rental(2920393, true, 334, 52.0,
    new RentDate(2026, 2, 12), new RentDate(2026, 4, 20)));
shops[2].addRental(new Rental(2910222, true, 5645, 65.0,
    new RentDate(2026, 2, 13), new RentDate(2026, 4, 20)));

(a)(i) State the outcome of IBIO.output(shops[1].getLocation()); [1]

(a)(ii) State the outcome of IBIO.output(shops[0].getRental(0).getCustomerID()); [1]

(a)(iii) State the outcome of IBIO.output(shops[2].getRental(1).getEndDate()); [1]

(b) Outline one ethical issue programmers need to consider when developing code for financial transactions. [2]

(c) Construct the code for the method getTotalIncome(), which finds the total cost of all rentals from all cars in all shops. You can use any previously constructed methods. [5]

(d) The Rental class is dependent on the RentDate class. Explain one reason why the programmers would want to reduce dependencies. [3]

(e) The programmers have worked in a team. Describe one advantage of working as a team. [2]

(a)(i)[1 mark]

  1. shops[1] was created with the location "Fjord View".

Answer:Fjord View

(a)(ii)[1 mark]

  1. The first rental added to shops[0] has customer ID 2920393.

Answer:2920393

(a)(iii)[1 mark]

  1. The second rental of shops[2] (index 1) is for car 5645, ending on RentDate(2026, 4, 20).
  2. getEndDate() returns a RentDate object, so what is printed is that object’s toString() value.

Answer:The end date of that rental, 20 April 2026 (RentDate(2026, 4, 20)). If RentDate does not override toString(), Java prints an object reference such as RentDate@1b6d3586.

(b)[2 marks]

  1. Customers trust that they are charged correctly. The programmers must make sure that calculations are accurate, for example avoiding rounding errors from using double for money, and that the code is fully tested.
  2. Overcharging (even by accident) would be unfair to customers and could damage trust or break the law.

Answer:Accuracy and honesty: the code must calculate charges correctly (for example avoid rounding errors) so customers are not overcharged (also: keeping customers’ financial data secure and private).

(c)[5 marks]

  1. Loop through every shop in the shops array (skipping any null entry).
  2. For each shop, loop through its rentals from 0 to getNoOfRentals() − 1 and add getCost() of each rental.
  3. Return the total.
public double getTotalIncome(RentalShop[] shops)
{
    double total = 0;
    for (int s = 0; s < shops.length; s++)
    {
        if (shops[s] != null)
        {
            for (int r = 0; r < shops[s].getNoOfRentals(); r++)
            {
                total = total + shops[s].getRental(r).getCost();
            }
        }
    }
    return total;
}

Answer:Nested loops over shops and their rentals, adding getCost() of each rental.

(d)[3 marks]

  1. When one class depends on another, a change in RentDate (for example renaming a method or changing how dates are stored) can force changes in Rental as well.
  2. Every dependent class then has to be modified and retested, which increases maintenance time and the risk of introducing new errors.
  3. Fewer dependencies (lower coupling) make classes easier to maintain, test and reuse independently.

Answer:Reducing dependencies (coupling) means that changing one class does not force changes and retesting in others, so the system is easier to maintain and less error-prone.

(e)[2 marks]

  1. The work can be divided so that different programmers write different classes at the same time, which speeds up development.
  2. Team members also bring different skills and can review each other’s code, catching errors.

Answer:Tasks are shared and done in parallel, so the program is finished faster (and code can be peer-reviewed).

Paper 2, Option D, Question 17: Linked lists of objects and libraries

10 marksOption D: object-oriented programming
The question

The company wants a linked list of Customer objects. When a shop closes, every customer who prefers it needs their preferredShop updated.

public class Customer
{
    private int customerID;
    private String customerName;
    private String preferredShop;

    public String getPreferredShop() { return preferredShop; }
    public void setPreferredShop(String shop) { preferredShop = shop; }
    // remaining accessor and mutator methods implemented but not shown
}

(a) Construct the method public int changePreferredShop(LinkedList customers, String preferredShop, String newShop), which changes the preferred shop of every affected customer to newShop and returns the number of customers changed. [6]

(b) Outline two benefits of using a library when developing code. [4]

(a)[6 marks]

  1. Traverse the linked list from the first to the last customer.
  2. Compare each customer’s preferred shop with the closed shop using equals() (Strings are compared by value).
  3. If they match, call setPreferredShop(newShop) and add 1 to a counter. Return the counter at the end.
public int changePreferredShop(LinkedList customers,
                               String preferredShop, String newShop)
{
    int count = 0;
    for (int i = 0; i < customers.size(); i++)
    {
        Customer c = (Customer) customers.get(i);
        if (c.getPreferredShop().equals(preferredShop))
        {
            c.setPreferredShop(newShop);
            count = count + 1;
        }
    }
    return count;
}

Answer:Traverse the list, update matching customers with setPreferredShop(newShop), count them and return the count.

Watch out: Use .equals() to compare Strings, not ==.

(b)[4 marks]

  1. Library code has already been written and thoroughly tested by many users, so it is reliable and has fewer bugs.
  2. It saves development time because the programmers do not need to write and test their own linked list, and the code is documented and usually efficient.

Answer:Reliability (already tested) and saving time (no need to write it yourself); also standard and well documented.

Paper 2, Option D, Question 18: Recursion and readability

10 marksOption D: object-oriented programming
The question

A programmer has produced the following recursive algorithm.

int X (int Y){
    if (Y <= 1){
        return Y;
    }
    else{
        return Y + X(Y-1);
    }
}

(a) Outline one benefit of recursion. [2]

(b) Trace the recursive algorithm when called with X(5). [4]

(c) Identify why calling the algorithm with X(-3) would cause an error. [1]

(d) Explain one action a programmer could take to improve the readability of code. [3]

Trace table for X(5): Y = 5, 4, 3, 2, 1; Y <= 1 is false except for Y = 1; the return calls are X(4), X(3), X(2), X(1) and none; the return values are 15, 10, 6, 3 and 1.YY <= 1Return callReturn value5false5 + X(4)154false4 + X(3)103false3 + X(2)62false2 + X(1)31true—1
Trace of X(5). The calls go down to X(1), then the values are added on the way back up.

(a)[2 marks]

  1. Some problems are defined in terms of smaller versions of themselves, such as tree traversals or adding the numbers from 1 to n.
  2. A recursive solution matches that definition, so the code is shorter and easier to read and write than an iterative version.

Answer:Recursion gives short, elegant code that mirrors problems that are naturally defined recursively (for example tree traversal).

(b)[4 marks]

  1. Each call with Y > 1 returns Y + X(Y − 1). The calls go down to the base case X(1), which returns 1, and then the values are added on the way back.
  2. Y = 5: Y ≤ 1 false, calls X(4), returns 15. Y = 4: false, calls X(3), returns 10.
  3. Y = 3: false, calls X(2), returns 6. Y = 2: false, calls X(1), returns 3.
  4. Y = 1: true, no further call, returns 1.

Answer:X(5) = 15 (it adds 5 + 4 + 3 + 2 + 1).

(c)[1 mark]

  1. −3 ≤ 1 is true, so the base case is reached immediately and −3 is returned. The program does not crash.
  2. The error is a logic error: X is meant to add the whole numbers from 1 to Y, and that sum makes no sense for a negative Y. The input is not validated.

Answer:It returns −3 straight away (the base case is met), which is a wrong, meaningless result: a logic error, because negative inputs are not validated.

(d)[3 marks]

  1. Use meaningful identifiers: rename X to sumUpTo and Y to n.
  2. Then anyone reading the code can see at once what the method does and what the parameter means, without tracing it.
  3. This makes the code easier to maintain and debug, especially in a team. (Comments and consistent indentation also help.)

Answer:Use meaningful names (for example sumUpTo(n) instead of X(Y)), so the purpose is clear, which makes the code easier to understand, maintain and debug.

COMPUTER SCIENCE HL · 4 MAY 2026

IB Computer Science HL May 2026 Paper 3 (case study): worked solutions

  • 4 May 2026, morning
  • 1 hour
  • 30 marks
  • Paper code 2226-4430

Paper 3 is based on the pre-released case study “An ethical approach to hacking”, about CyberHealth Security testing the network of MedTechPro Hospital (MTPH) using the PTES process. The short summary in each question gives the context the answer needs.

Paper 3 (case study), Question 1: Network topologies and the PTES pre-engagement phase

4 marksCase study: ethical hacking
The question

The case study: CyberHealth Security has been hired to review the cybersecurity of MedTechPro Hospital (MTPH) using the penetration testing execution standard (PTES). In the pre-engagement interactions phase, boundaries and limits are defined.

(a) Identify two types of network topology. [2]

(b) Outline one limit that might be agreed upon during the pre-engagement interactions phase of the PTES process. [2]

(a)[2 marks]

  1. A topology is the layout of how devices are connected.

Answer:Star and bus (also ring, mesh, tree/hierarchical).

(b)[2 marks]

  1. In a hospital some systems keep patients alive or support care, so testing must never disrupt them.
  2. A typical limit: no testing of life-critical IoT medical devices, or testing only outside peak hours, so that patient care and critical services are not interrupted.

Answer:Life-critical IoT medical devices are excluded (or testing happens only at agreed times), so that the test cannot disrupt patient care.

Paper 3 (case study), Question 2: OSINT and network scanning

8 marksCase study: ethical hacking
The question

In the intelligence-gathering phase the team uses open-source intelligence (OSINT) and network scanning.

(a) Describe one benefit and one limitation of using OSINT techniques in the intelligence-gathering phase of the PTES process. [4]

(b) Describe the process of network scanning. [4]

(a)[4 marks]

  1. Benefit: OSINT uses only publicly available information (social media, websites, public records), so it is legal, cheap and does not touch the hospital’s systems. It shows the team exactly what a real attacker could learn, such as staff names in IT roles or the technologies in use.
  2. Limitation: public information may be out of date, incomplete or deliberately false, and there can be a huge amount to sift through, which takes time. Collecting personal details about staff also raises privacy concerns.

Answer:Benefit: legal, low-cost and non-intrusive, and it reveals what an attacker could find (for example staff details). Limitation: the information can be inaccurate or out of date and is time-consuming to analyse.

(b)[4 marks]

  1. Host discovery: the team sends probes (for example a ping sweep) across the agreed IP ranges to find which devices are live.
  2. Port scanning: each live host is checked for open ports, which show the services that are running.
  3. Service and OS detection: the responses are used to identify the software versions and operating systems (OS fingerprinting).
  4. The results are catalogued, with the IP address of every device, to build a map of the network topology and to point to possible vulnerabilities for later phases.

Answer:Discover live hosts, scan their ports, identify services and operating systems, then catalogue IP addresses and map the network to find likely vulnerabilities.

Paper 3 (case study), Question 3: Automated tools and manual techniques in vulnerability analysis

6 marksCase study: ethical hacking
The question

Automated tools and manual techniques are used in the vulnerability analysis phase of the PTES process.

Explain two benefits of using automated tools and manual techniques together to conduct vulnerability analysis. [6]

[6 marks]

  1. Benefit 1: speed and coverage, plus accuracy. Automated scanners can check thousands of hosts in the hospital network quickly against large databases of known vulnerabilities. Manual testers then verify the results, removing false positives, so the hospital gets a complete and accurate list without wasting effort on non-issues.
  2. Benefit 2: depth. Manual techniques find what tools miss: logic flaws in the electronic health record (EHR) system, weaknesses that only appear when several small issues are chained together, and problems specific to unusual IoT medical devices.
  3. Testers can also judge risk in context and test fragile medical devices carefully, where an aggressive automated scan could disrupt patient care.
  4. Together the two approaches give broad, fast coverage and expert depth, which is what a hospital with sensitive data and critical systems needs.

Answer:Automated tools give fast, wide coverage of known vulnerabilities and manual checks confirm them (fewer false positives); manual testing adds depth, finding logic flaws and chained or device-specific weaknesses that tools miss, while protecting fragile medical systems.

Watch out: For 6 marks: name each benefit, explain how it works and link it to the hospital.

Paper 3 (case study), Question 4: Justifying a comprehensive incident response plan

12 marksCase study: ethical hacking
The question

MTPH aims to implement a comprehensive response plan that includes proactive measures, such as the PTES process, as well as reactive measures.

Justify the implementation of a comprehensive response plan that includes proactive measures and reactive measures for managing cybersecurity incidents at MTPH. [12]

The seven phases of the penetration testing execution standard in order: pre-engagement interactions, intelligence gathering, threat modelling, vulnerability analysis, exploitation, post-exploitation and reporting.1. Pre-engagement interactions2. Intelligence gathering3. Threat modelling4. Vulnerability analysis5. Exploitation6. Post-exploitation7. Reporting
The seven PTES phases from the case study, in order.

[12 marks]

  1. Context: a hospital stores highly sensitive electronic health records, depends on internal communications, and uses IoT medical devices. An attack can endanger patients as well as data, and hospitals are frequent targets of ransomware.
  2. Proactive measures reduce the chance of an incident: regular penetration testing with PTES finds and fixes vulnerabilities before attackers do; threat modelling ranks the most valuable assets (EHRs, IoT devices); patching, network segmentation and strong authentication shrink the attack surface; staff training defends against social engineering such as vishing and pretexting.
  3. But proactive measures can never remove all risk: there are zero-day vulnerabilities, insider threats and human error. So reactive measures are essential to limit the damage when an incident does happen.
  4. Reactive measures: an incident response plan with clear roles for detecting, containing (isolating infected systems), eradicating and recovering; secure, tested backups so EHRs can be restored without paying a ransom; communication plans for staff, patients and regulators; and forensic analysis of what happened.
  5. The two parts reinforce each other: lessons from each incident feed back into the next round of proactive testing, and the PTES report identifies which systems must be recovered first.
  6. Considerations: the plan costs money, time and staff training, and testing must be scheduled so it does not disrupt care. However, the cost is small compared with a data breach, legal penalties under health data regulations, loss of trust or harm to patients.
  7. Conclusion: a comprehensive plan that combines proactive and reactive measures is justified for MTPH, because it lowers the probability of an attack and also minimizes the impact and recovery time when one gets through, protecting both patient data and patient safety.

Answer:Proactive measures (PTES testing, patching, training, segmentation) reduce the likelihood of incidents, but cannot stop every attack; reactive measures (incident response, backups, containment, communication) limit the impact. Given sensitive EHRs, patient safety and legal duties, combining both is justified despite the cost.

Watch out: For 12 marks: cover proactive and reactive measures, link them to the case study, weigh costs against benefits and end with a clear judgement.

What the three papers test: topic map

The topic map groups the questions into five areas. Programming and data structures (recursion, linked lists, binary search and 2D arrays) carries the most marks in Paper 1, and each Paper 2 option adds 65 marks. You only need the option your school teaches. Use the tables to find every question on a topic you want to practise.

Marks by topic area across the three papers
Syllabus areaQuestionsMarksShare of marks
Option A: databases46517%
Option B: modelling and simulation46517%
Option C: web science56517%
Option D: object-oriented programming56517%
Programming and data structures73910%
Computer organization and control4379%
Case study: ethical hacking4308%
System fundamentals and networks4246%
Every question, its topic and its marks
QuestionTopicAreaMarks
Paper 1 Q1Comparing types of computersSystem fundamentals and networks3
Paper 1 Q2Shared resources on a LANSystem fundamentals and networks2
Paper 1 Q3Stack method pop()Programming and data structures1
Paper 1 Q4Stack method isEmpty()Programming and data structures1
Paper 1 Q5Representing colour in binaryComputer organization and control3
Paper 1 Q6Truth table from a descriptionComputer organization and control4
Paper 1 Q7Operations on a doubly linked listProgramming and data structures4
Paper 1 Q8Network protocolsSystem fundamentals and networks4
Paper 1 Q9TranslatorsProgramming and data structures1
Paper 1 Q10DebuggingProgramming and data structures2
Paper 1 Q11Prototypes, parallel running and email securitySystem fundamentals and networks15
Paper 1 Q12Memory, the operating system and the CPUComputer organization and control15
Paper 1 Q13Taxi meters and GPSComputer organization and control15
Paper 1 Q14Static arrays, recursion and binary searchProgramming and data structures15
Paper 1 Q15Two-dimensional arrays: concert ticketsProgramming and data structures15
Paper 2, Option A Q1ER diagrams, timestamps, concurrency and recoveryOption A: databases16
Paper 2, Option A Q2Primary keys, data types, SQL and 3NFOption A: databases14
Paper 2, Option A Q3Schemas, data dictionaries, DDL and securityOption A: databases15
Paper 2, Option A Q4Data warehousing and data miningOption A: databases20
Paper 2, Option B Q5Spreadsheet formulas and text functionsOption B: modelling and simulation15
Paper 2, Option B Q6Scaling scores to another rangeOption B: modelling and simulation12
Paper 2, Option B Q7Real-time simulation of attendanceOption B: modelling and simulation18
Paper 2, Option B Q8Genetic algorithms, chatbots and natural languageOption B: modelling and simulation20
Paper 2, Option C Q9URLs, browsers, protocols, XML and XSLTOption C: web science14
Paper 2, Option C Q10Deep web, web crawling and SEOOption C: web science15
Paper 2, Option C Q11Ubiquitous computing and distributed social networksOption C: web science16
Paper 2, Option C Q12Weighted directed graphs and PageRankOption C: web science10
Paper 2, Option C Q13Ambient intelligence and the IoTOption C: web science10
Paper 2, Option D Q14Classes, objects, overloading and getCost()Option D: object-oriented programming15
Paper 2, Option D Q15Encapsulation, protected access and arrays of objectsOption D: object-oriented programming15
Paper 2, Option D Q16Testing, ethics, getTotalIncome() and dependenciesOption D: object-oriented programming15
Paper 2, Option D Q17Linked lists of objects and librariesOption D: object-oriented programming10
Paper 2, Option D Q18Recursion and readabilityOption D: object-oriented programming10
Paper 3 (case study) Q1Network topologies and the PTES pre-engagement phaseCase study: ethical hacking4
Paper 3 (case study) Q2OSINT and network scanningCase study: ethical hacking8
Paper 3 (case study) Q3Automated tools and manual techniques in vulnerability analysisCase study: ethical hacking6
Paper 3 (case study) Q4Justifying a comprehensive incident response planCase study: ethical hacking12

How to revise from these papers

Paper 1. Section A has short answers, about one minute per mark. In Section B, spend the most time on the “construct” questions: trace your algorithm with the example data given in the question before you move on.

Paper 2 options. In Option A, practise SQL joins and normalising to 3NF. In Option B, practise spreadsheet lookups and text functions. In Option C, learn graph terms and how PageRank works. In Option D, read the class listings carefully and reuse their methods, such as getDays(), getStartDate().compareTo() and getNoOfRentals(). Loop only up to the number of items stored, compare Strings with equals(), and practise tracing recursion in a table.

Paper 3. Learn the case study vocabulary (PTES phases, OSINT, network scanning, vishing, pretexting, black, white and grey box testing) and always link your answer to the hospital: patient data, IoT medical devices and uninterrupted care.

Work by topic. After a first pass, redo the questions for your weakest syllabus area in the topic map. Seeing three or four questions on the same idea from different papers is the quickest way to see what the examiners expect.

A LITTLE MORE CLARITY

IB Computer Science HL May 2026 FAQs

Papers, marks, time zones and how to use the worked solutions.

Tell us about your needs
What are the IB Computer Science HL May 2026 papers?

They are the three written papers for Higher Level Computer Science in May 2026. Paper 1 (30 April 2026, afternoon, 2 hours 10 minutes, 100 marks) covers the core and HL extension. Paper 2 (4 May 2026, morning, 1 hour 20 minutes, 65 marks) is the option paper. Paper 3 (4 May 2026, morning, 1 hour, 30 marks) is based on the pre-released case study.

Which papers are solved on this page?

All of them: Paper 1 (15 questions, 100 marks), every Paper 2 option (A databases, B modelling and simulation, C web science and D object-oriented programming; 18 questions, 65 marks each) and Paper 3 (4 questions, 30 marks). That is 37 questions and 390 marks in total.

Which Paper 2 option should I look at?

Paper 2 has four options: A databases (questions 1 to 4), B modelling and simulation (5 to 8), C web science (9 to 13) and D object-oriented programming (14 to 18). Each student answers only the option their school teaches, so jump straight to yours using the contents list.

What was the Paper 3 case study for May 2026?

The case study “An ethical approach to hacking” follows CyberHealth Security as it tests the network of MedTechPro Hospital (MTPH) using the seven phases of the penetration testing execution standard (PTES): pre-engagement interactions, intelligence gathering, threat modelling, vulnerability analysis, exploitation, post-exploitation and reporting.

Do I need to write exact Java, SQL or pseudocode syntax?

Examiners mark the logic: correct loops, conditions, use of the right methods and a correct return value. Small syntax slips are usually not penalised, but the algorithm must work for every case, for example looping only up to the number of items stored.

Are these the official IB mark schemes?

No. These are original worked solutions written for learners and are not published or approved by the IB. Many questions accept several valid answers, so the solutions show one strong answer and often mention alternatives. For official mark schemes, ask your teacher or use the IB’s own materials.

How do I answer the long Paper 3 questions?

Use the vocabulary of the case study, link every point to the scenario (here the hospital, its patient data and IoT devices), cover both sides where asked, and finish with a justified conclusion. The 12-mark question is marked with level descriptors, so depth and structure matter.

What do the command terms mean?

State, identify and list need short answers. Outline needs a brief explanation. Describe and explain need detail and reasons. Construct means write working pseudocode or code. Evaluate, discuss and justify need balanced arguments and a conclusion. The table on this page lists them all.

How should I use these solutions to study?

Attempt each question first under time pressure, about one minute per mark. Then compare your answer with the steps, check the red notes for common mistakes, and rewrite any algorithm you got wrong without looking a few days later.

YOUR NEXT STEP STARTS HERE

Want help with IB Computer Science?

Work one to one with a tutor on pseudocode, SQL, Java, your Paper 2 option and the case study, and turn these papers into marks.

Explore IB tutoring