Multiple choiceQuestion 1 · Recall
Loading…
By the end you can use array terminology (index, upper bound, lower bound), choose between 1D and 2D arrays, declare and fill arrays in pseudocode, and write pseudocode for bubble sort and linear search.
An array is a fixed-size, ordered collection of elements of the same data type.
| Term | Meaning |
|---|---|
| Index | Position of an element (in 9618 pseudocode, usually counted from 1) |
| Lower bound (LB) | Smallest valid index (typically 1) |
| Upper bound (UB) | Largest valid index. It equals the number of elements only when the lower bound is 1. (In general, the number of elements is UB - LB + 1.) |
| Element | A single value stored at an index |
In Cambridge pseudocode, arrays are usually 1-indexed: the first element is at index 1, and the last is at the upper bound.
Declaration syntax:
DECLARE Scores : ARRAY[1:10] OF INTEGER
DECLARE Names : ARRAY[1:5] OF STRING
DECLARE Matrix : ARRAY[1:3, 1:4] OF REAL // 2D: 3 rows × 4 columns