This is the heaviest part of the exam, 30–35% of the multiple-choice questions. You read short programs written with the Exam Reference Sheet's code and work out what they do: the value of a variable, what is displayed, what a list holds, where a robot ends up. Other questions ask about algorithms in plain words: binary search, efficiency, heuristics, simulations and problems no algorithm can fully solve.
- variable
- An abstraction inside a program that holds one value at a time; that value can be a list holding many values. Meaningful names make code easier to read.
- Example: highScore holds 0 when a game starts and 4500 after a new record; the name says what it stores.
- list
- An ordered sequence of elements, each with a unique index. A list lets many related items be treated as one value; some languages call it an array.
- Example: temps ← [61, 58, 64] makes a three-element list; copy ← temps then gives copy its own list [61, 58, 64].
- algorithm
- A finite set of instructions that accomplish a specific task. Algorithms that programs carry out are written in programming languages.
- Example: A recipe's numbered steps for baking bread form an algorithm: a finite, ordered list aimed at one result.
- Boolean value
- A value that is either true or false. Relational operators produce Boolean values, and logical operators take them as operands.
- Example: isRaining ← true stores a Boolean value; the expression 7 > 9 evaluates to false.
- iteration
- A repeating portion of an algorithm. Iteration statements repeat a set of statements a specified number of times or until a condition is met, possibly zero times.
- Example: "Stir the sauce until it thickens" is iteration in a natural-language algorithm.
- equivalent algorithms
- Different algorithms that give the same result or side effect for every input. Algorithms that look similar can still give different results.
- Example: Adding 1 to n three times and the single statement n ← n + 3 always leave n with the same value.
- accessing a list element
- Using aList[i] to work with the element at index i: x ← aList[i] copies it into x, and aList[i] ← x replaces it.
- Example: With pets ← ["cat", "dog", "fish"], pets[3] ← "bird" changes the list to ["cat", "dog", "bird"].
- procedure
- A named group of programming instructions that may have parameters and return values. Other languages call it a method or a function.
- Example: PROCEDURE greet(name) { DISPLAY("Hello") DISPLAY(name) } can be called whenever the program needs a greeting.
- RANDOM
- RANDOM(a, b) returns a random integer from a to b, including a and b, each equally likely. A program using it may give different results each run.
- Example: RANDOM(1, 6) models one roll of a six-sided die: it returns 1, 2, 3, 4, 5 or 6.
- decision problem
- A problem with a yes-or-no answer. A problem is a general task; an instance of the problem also includes specific input.
- Example: "Is this number prime?" is a decision problem; "Is 91 prime?" is one instance of it (no: 91 = 7 × 13).
- data type
- The kind of value a variable holds. Types include numbers, Booleans, lists and strings, and some values suit one type better than another.
- Example: A ZIP code like 02134 is better stored as a string than a number, because its leading 0 must stay.
- index
- A natural number that refers to an element's position in a list or string. In the exam's language, the first element is at index 1, not 0.
- Example: With colors ← ["red", "blue", "green"], colors[2] is "blue".