Skip to content

9618 · 10.2

Arrays — common mistakes

Common exam mistakes on 9618 Arrays. Learn what loses marks, then practise the topic with Examiner’s Ink.

Exam tip 1

Pay close attention to the syntax. A single mistake like using parentheses () instead of square brackets [], forgetting the OF<datatype>OF <data_type> part, or missing the DECLARE keyword can cost you marks. Always use 1-based indexing ([1:N]) in exams unless the question explicitly states otherwise.

Exam tip 2

When finding a maximum or minimum, a common technique is to initialise your tracking variable (HighestScore in the example) with the value of the first element in the array. Then, loop from the second element to the end. This avoids issues with choosing an arbitrary initial value (like 0) that might be incorrect if all array values are negative, for instance.

Why do some programming languages start array indices at 0, but Cambridge pseudocode often uses 1?

0-based indexing (starting at 0) is common in languages like Python, Java, and C++ because the index represents an 'offset' from the starting memory address of the array. The first element is at offset 0. However, 1-based indexing (starting at 1) is often more intuitive for humans ('the first item', 'the second item'). Cambridge pseudocode allows either but typically uses 1-based indexing in exam questions. It's crucial to be consistent and follow the bounds given in the question.

What's the difference between an array and a list?

In the context of A-Level Computer Science, the key difference is that an array is a static data structure, meaning its size is fixed upon creation. A list is typically a dynamic data structure, meaning it can grow or shrink as needed. For your exams, especially in Paper 2 pseudocode, you will almost always be working with static arrays.

What happens if I try to access an index that doesn't exist?

This causes a run-time error called an 'index out of bounds' error. For an array declared as MyData : ARRAY[1:10] OF INTEGER, trying to access MyData[0] or MyData[11] would trigger this error. Your program would likely halt. It's a common logical error that you must guard against in your code, for example by ensuring loop bounds are correct.

Can I store different data types in the same array?

No. An array is a homogeneous data structure, which means all its elements must be of the same data type specified in the declaration (e.g., all INTEGER or all STRING).