9618 · 10.2
Arrays flashcards
Revision flashcards for Cambridge 9618 Arrays (syllabus 10.2). Flip, recall, then mark a real past-paper question.
Card
What is an array?
A static, finite, ordered set of elements of the same data type, stored in contiguous memory locations under a single identifier.
Card
What is an 'element' in an array?
A single data item stored within an array.
Card
What is an 'index' or 'subscript'?
A numerical value used to identify the position of a specific element within an array. For example, in `Scores[5]`, the index is 5.
Card
What is the 'lower bound' of an array?
The smallest index value in an array. In `DECLARE A : ARRAY[1:10]`, the lower bound is 1.
Card
What is the 'upper bound' of an array?
The largest index value in an array. In `DECLARE A : ARRAY[1:10]`, the upper bound is 10.
Card
How do you declare a 1D array in Cambridge pseudocode?
`DECLARE <identifier> : ARRAY[<lower_bound>:<upper_bound>] OF <data_type>`
Card
What does it mean to 'traverse' an array?
To access and process every element in the array, usually in order from the lower bound to the upper bound, typically using a `FOR` loop.
Card
What is an 'index out of bounds' error?
A run-time error that occurs when a program tries to access an array element with an index that is outside the valid range of its lower and upper bounds.
Card
Why is an array described as a 'static' data structure?
Because its size is fixed when it is declared and cannot be changed during program execution. The number of elements is determined at compile-time.
Card
Give an example of a problem where an array is the ideal data structure.
Storing the test scores for 30 students in a class, storing the daily temperature for a month, or holding the names of players on a team.
Card
How do you calculate the number of elements in an array declared as `ARRAY[L:U]`?
The number of elements is `U - L + 1`. For `ARRAY[1:10]`, it's `10 - 1 + 1 = 10` elements.