Computer Science • Pseudocode

A Level Pseudocode

A Level Pseudocode — Explanation

Write A Level pseudocode the way the Cambridge International AS & A Level Computer Science (9618) papers expect it, then run it. Everything from AS pseudocode applies (declarations, data types, the ← arrow: type <--, or press the ← button), checked strictly against the 9618 Pseudocode Guide for Teachers, and the A Level parts of the guide too:

As in the papers, a question gives a specification and you write the function, procedure or class: a test program, shown under How it's tested, runs after your code. Run, Step and the trace table show what your code does; a recursive call that never stops is caught and explained.

Check answer runs your code on the question's tests, some of them hidden. If it's not right, you're told which test it failed and what that suggests, never the answer. Hint halves the question's marks; Show me shows code that works, and the question scores nothing. Playground is a free editor. Signed in, your code is saved as you go, and topics your teacher has set come up first.

Objective: Cambridge International AS & A Level Computer Science 9618, A Level topics 13.1 User-defined data types, 13.2 File organisation and access (random files), 19.1 Algorithms (binary search, insertion sort, stacks, queues and linked lists), 19.2 Recursion and 20.1 Programming paradigms (object-oriented programming), written as set out in the 9618 Pseudocode Guide for Teachers.

Where this fits

  • Cambridge: Cambridge A Level Computer Science (9618)

A Level Pseudocode — Key Terms

Key concepts in English, with te reo Māori, Chinese (Simplified) and Korean.

EnglishTe reo Māori中文(简体)한국어What it means on this page
Constantno attested term——A named value that is set when it's declared and can't be changed while the program runs, such as CONSTANT Rate = 0.15.
Declarationno attested term——A statement that names a variable and gives its data type before it's used, such as DECLARE Total : INTEGER.
Assignmentno attested term——Giving a variable a value. Pseudocode writes it with an arrow: Total ← 0.
Parameterno attested term——A value passed to a procedure or function when it's called, named in its header, such as Size in PROCEDURE Line(Size : INTEGER).
Recordno attested term——A data structure that groups related items of different data types under one name; each item is a field.
By Referenceno attested term——Passing a parameter as the caller's own variable (its address), so a change made in the subroutine changes the caller's variable too (BYREF).
By Valueno attested term——Passing a copy of a value as a parameter, so a change made in the subroutine doesn't affect the caller's variable (BYVAL).
Recursionno attested term——A subroutine calling itself to solve a smaller version of the same problem, with a base case that stops the calls.
Base Caseno attested term——The condition in a recursive subroutine that gives a result without calling itself again, so the recursion stops.
Binary Searchno attested term——Searching a sorted list by looking at the middle item and discarding the half that can't hold the target, until it's found or nothing is left.
Insertion Sortno attested term——A sort that takes each item in turn and inserts it into its place among the items before it, which are already in order.
Stackno attested term——A last in, first out (LIFO) data structure: items are pushed on and popped off at the top.
Queueno attested term——A first in, first out (FIFO) data structure: items join at the tail and leave from the head.
Linked Listno attested term——A list in which each node holds its data and a pointer to the next node, so the order doesn't depend on where the nodes are stored.
Pointerno attested term——A variable that holds the address (or index) of another item, such as the next node in a linked list.
Classno attested term——A blueprint for objects: it defines their properties (attributes) and methods.
Objectno attested term——An instance of a class, with its own values for the class's properties.
Inheritanceno attested term——A class (a subclass) taking on the properties and methods of another class (its superclass), and adding or changing its own.
Constructorno attested term——The method that runs when an object is created and sets its properties; in 9618 pseudocode, the procedure NEW.
Enumerated Typeno attested term——A user-defined data type whose values are a fixed list of names, such as TYPE Season = (Spring, Summer, Autumn, Winter).
Pseudocodeno attested term伪代码의사코드A structured, language-independent way of writing an algorithm, using keywords like IF, FOR and WHILE.
Arrayhuānga数组배열An ordered list of values, all referred to by one name and an index, e.g. Numbers[3].
Functiontaumahi函数함수A named block of instructions that returns a value back to where it was called.
Procedurearamahi过程프로시저A named block of instructions that is run (CALLed) but does not return a value.
Trace tableno attested term追踪表추적표A table used to record the value of each variable, row by row, as an algorithm is dry-run by hand.
Random Access Fileno attested term随机存取文件 (suíjī cúnqǔ wénjiàn)임의 접근 파일 (imui jeopgeun pail)A file where a record's address is worked out from its key (by hashing), so it can be read directly, without reading others first.

On the te reo Māori column. Terms marked as gaps have no attested equivalent in the sources checked — Karaitiana Taiuru's Dictionary of Māori Computer and Social Media Terms, Paekupu, the Reserve Bank's te reo financial glossary, NZQA and Te Aka. No coinage is printed as though it were established; where a class needs one, commission it from Te Taura Whiri i te Reo Māori and credit the translator. Te reo Māori is not italicised and takes no plural "s".