Software Design & Development · Implementation

SDD5 — Parallel Arrays

📅 Mon 15 Jun 2026 · P1+P2 (double)
~120 minutes
Learning intentions
Success criteria
Warm up — recap and foundations
Answer all three questions, then check your answers.
Question 1
In SDD4 you wrote a refinement using a loop that repeats a known number of times. What is this type of loop called?
Question 2
What is the term for a single value stored inside an array, accessed via its position number?
Question 3
In Python, array (list) indexing starts counting from which number?

Key vocabulary

Parallel arrays
Two or more separate 1D arrays where the same index position across every array refers to data about the same real-world item.
Index (subscript)
The position number used to access a specific element in an array. In Python, indexing starts at 0.
Element
A single value stored inside an array at a particular index.
Traversal
Visiting every element of an array in order, typically using a fixed loop.
Synchronisation
Keeping parallel arrays the same length and in the same order, so a shared index always refers to the same item.

Storing related data with parallel arrays

What is a parallel array?

A single 1D array can only store one attribute — one list of values. Most real problems need to store several different attributes about the same set of items: a name, a price, a quantity in stock, and so on. A parallel array solves this by using two or more separate 1D arrays, one per attribute, where the same index position in every array refers to the same real-world item. If itemNames[2] is "Chocolate", then itemPricesPence[2] and itemStock[2] must also describe that same chocolate — not some other item. Nothing in Python links the arrays together automatically; the relationship exists only because the programmer is careful to keep every array the same length, in the same order, and always indexed with the same counter variable.

Why use parallel arrays instead of one array?

Parallel arrays let a program model several attributes of the same set of items using only simple 1D array syntax, without needing a more advanced structure. This makes them a natural stepping stone before records and arrays of records (SDD6), which group all the attributes of one item together in a single structured variable instead of splitting them across separate arrays. Parallel arrays are simple to declare and easy to traverse with a single fixed loop, which is exactly why they appear in the Higher specification as their own named data structure, separate from records.

Declaring and populating parallel arrays in Python

In Python, each array in a parallel set is declared as its own list, using square brackets. For example, a small tuck shop stock system might use three separate lists — one for names, one for prices, and one for stock levels — created in the same order so that position 0 in every list describes the same item, position 1 describes the next item, and so on. The three lists must always be built and updated together: adding, removing, or reordering an item in one list without doing the exact same thing, at the exact same position, in every other list is the single most common way parallel arrays break.

Traversing parallel arrays with a common index

Once several arrays are parallel, a fixed loop can read from all of them at once by using one shared index variable across every array in the loop body. On each pass of the loop, the same value of that index variable is used to look up the matching element in every parallel array, so all the values read together on a single pass genuinely describe one item. This single-index traversal pattern is the foundation for later standard algorithms — linear search, finding a minimum or maximum, and counting occurrences (SDD13–14) — which all rely on being able to look up several related values using one matching index at a time.

Worked examples

Example 1 — Declaring and traversing parallel arrays
1
Scenario: a school tuck shop stores the name, price (in pence), and stock level of four items.
itemNames = ["Crisps", "Juice", "Chocolate", "Water"]
itemPricesPence = [60, 90, 75, 50]
itemStock = [24, 15, 30, 40]
2
All three arrays are the same length (4), and built in the same order, so index 0 describes Crisps in every array, index 1 describes Juice, and so on.
3
A fixed loop uses one shared index, i, to print every item's full details on one line:
for i in range(len(itemNames)):
    print(itemNames[i], "costs", itemPricesPence[i], "pence, stock:", itemStock[i])
At i = 2, itemNames[2] is "Chocolate", itemPricesPence[2] is 75, and itemStock[2] is 30 — the same index gives three facts about the same item.
i=0
i=1
i=2
i=3
itemNames
Crisps
Juice
Chocolate
Water
itemPricesPence
60
90
75
50
itemStock
24
15
30
40
Example 2 — Using a shared index to search across arrays
1
Using the same three arrays, a program looks up the price of an item by name:
search = "Juice"
for i in range(len(itemNames)):
    if itemNames[i] == search:
        print("Price:", itemPricesPence[i])
2
The loop checks itemNames[i] against search on every pass, but never looks at itemPricesPence directly for the comparison.
3
At i = 1, itemNames[1] equals "Juice", so the condition is true, and the same index, 1, is then used to read itemPricesPence[1].
The program prints Price: 90 — the match was found in one array, but the shared index i was used to retrieve the related value from the other array. This is the same principle behind linear search, covered later in SDD13.
Example 3 — Tracing a running total across a parallel array
1
This code adds up the total stock held across all four items:
totalStock = 0
for i in range(len(itemStock)):
    totalStock = totalStock + itemStock[i]
print(totalStock)
2
Tracing the loop using itemStock = [24, 15, 30, 40]:
3
i=0: itemStock[0]=24 → totalStock = 0 + 24 = 24
i=1: itemStock[1]=15 → totalStock = 24 + 15 = 39
i=2: itemStock[2]=30 → totalStock = 39 + 30 = 69
i=3: itemStock[3]=40 → totalStock = 69 + 40 = 109
The loop finishes after i = 3 (there are 4 elements, indices 0–3), and the final printed value is 109.
Now you try
A school library uses two parallel arrays:
bookTitles = ["Wasp Factory", "Room", "1984", "Educated"]
dueDates = ["12 Jul", "15 Jul", "18 Jul", "20 Jul"]

Write a fixed loop that prints, for every book, a line in the form Title: <title> — Due: <date>.
⚠️ Common mistakes — examiner feedback
📝 Exam tip

When asked to implement or trace code using parallel arrays, always use exactly one loop counter variable to index every array in the group on each pass. Introducing a second, separate counter — even by accident — breaks the implicit link between arrays and is one of the most common ways marks are lost in this topic.

Task Set A — Core questions

Task Set A — Core questions
Work through all questions, then check your answers.
Question 1
What term describes two or more separate arrays where the same index position refers to data about the same real-world item?
Question 2
Why might a programmer use parallel arrays rather than a single array?
Question 3
Given itemNames = ["Crisps", "Juice", "Chocolate", "Water"] and itemPricesPence = [60, 90, 75, 50], what is the value of itemPricesPence[2]?
Question 4
A programmer adds a new item to itemNames using itemNames.append("Crisps XL") but forgets to add a matching new price to itemPricesPence. What is the most likely consequence?
Question 5
Which statement about parallel arrays is correct?
Question 6
Using itemStock = [24, 15, 30, 40] and the fixed loop for i in range(len(itemStock)): totalStock = totalStock + itemStock[i], starting with totalStock = 0, what is the final value of totalStock?
Question 7
Explain, using the tuck shop arrays as an example, what would go wrong if itemNames and itemPricesPence became different lengths. (3 marks)
Question 8
Write Python code that declares two parallel arrays, bookTitles = ["Wasp Factory", "Room", "1984"] and bookAuthors = ["Iain Banks", "Emma Donoghue", "George Orwell"], then uses a fixed loop to print each title with its author in the form <title> by <author>.
bookTitles = ["Wasp Factory", "Room", "1984"]
bookAuthors = ["Iain Banks", "Emma Donoghue", "George Orwell"]

for i in range(len(bookTitles)):
    print(bookTitles[i], "by", bookAuthors[i])
Question 9
A search loop finds itemNames[i] == "Chocolate" when i = 2. Using itemStock = [24, 15, 30, 40], which value correctly gives the stock of chocolate?
Question 10
Describe how a fixed loop uses a single index variable to read from three parallel arrays at once. (3 marks)

Task Set B — Extension

Task Set B — Extension · Beyond the specification
Longer written answers — no auto-check. Discuss your answers with your teacher.
Extension 1
A colleague suggests combining itemNames, itemPricesPence, and itemStock into a single array of records instead (a topic in the next lesson). Suggest one advantage and one disadvantage of parallel arrays compared to a single array of records.
Extension 2
A pupil wants to insert a new item, "Fizzy Drink" priced 85p with stock 20, at position 1 in the tuck shop arrays (before "Juice"). Explain what must be done to all three arrays to keep them correctly parallel.
Extension 3
Some more advanced courses use a single 2D array instead of several parallel 1D arrays for this kind of data. Suggest why a 2D array is not required at this level, but might be useful in a more advanced course.
📁 File this in OneNote under:
Higher Computing Science → Software Design & Development → SDD5
📌 Teacher notes — not for pupils

Double period. This is the first Implementation-strand lesson using real Python code rather than pseudocode/design — worth flagging explicitly, since pupils have been working in pseudocode/structure diagrams/wireframes since SDD3–4.

Suggested timing: 10 min warm-up + vocab · 25 min notes + examples 1–2 (live-code the tuck shop arrays in PyCharm alongside the slides) · 15 min example 3 trace table (do this one on the whiteboard together before pupils see the answer) · 10 min "now you try" · 45 min Task Set A · remaining time Task Set B / homework.

Key misconception: pupils often assume Python automatically keeps separate lists "linked" because they were declared near each other, or that appending to one list updates the others. Live-demonstrate breaking a parallel array on purpose (append to one list only) and show the resulting mismatch when the loop runs.

SQA command words covered: describe, explain, implement, trace.

Extension suggestion: Extension 3 deliberately connects to the Advanced Higher 2D array content — useful for stretching pupils who ask "why not just use a 2D array?", a question that comes up almost every year.