Revision Notes
Cambridge A Level Computer Science (9618): User-defined Data Types – Revision Notes
Revision notes for 9618 section 13.1: enumerated, pointer, set, record and class types, their pseudocode, choosing a type, traps and a self-test.
- Subject
- Computer Science
- Level
- A LEVEL
- Topic
- Topic 13: Data Representation
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to Cambridge A Level Computer Science (9618), 2026. Official specification .
Syllabus page (what it covers and how it is assessed): Cambridge A Level Computer Science.
Syllabus points this page covers
9618 (A Level)
- 13.1 User-defined data types
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9618).
Condensed notes for 13.1 User-defined data types, A Level content in Cambridge International AS & A Level Computer Science 9618, examined in Paper 3. You need to explain why user-defined types are necessary, define and use the non-composite types (enumerated, pointer) and the composite types (set, record, class/object), and choose and design a suitable type for a problem.
Related: User-defined Data Types study guide · User-defined Data Types practice questions · Data Representation (A Level) revision notes
Why define your own types?
- Built-in types cannot describe every kind of data a problem uses.
- A user-defined type models the problem, making code clearer.
- It restricts values, so invalid data is rejected by the translator.
- It groups related data so it can be stored and passed as one unit.
- It is defined once and reused, giving consistent handling.
The five types at a glance
| Type | Composite? | Holds | Pseudocode pattern |
|---|---|---|---|
| Enumerated | Non-composite | One value from an ordered list of named values | TYPE TLight = (Red, Amber, Green) |
| Pointer | Non-composite | The memory address of a value of a stated type | TYPE TIntPointer = ^INTEGER |
| Record | Composite | Named fields of possibly different types | TYPE TBooking … ENDTYPE with DECLARE lines |
| Set | Composite | Distinct, unordered values of one base type | TYPE TCharSet = SET OF CHAR, then DEFINE Vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) : TCharSet |
| Class | Composite | Attributes and the methods that act on them | CLASS … ENDCLASS |
Using each type
- Enumerated: Signal ← Amber (no quotation marks). Values are ordered, so they can be compared.
- Pointer: Ptr ← ^Stock stores Stock’s address. Ptr^ is the value at that address; Ptr^ ← 0 changes Stock. Changing Ptr changes only where it points.
- Record: Booking.Nights ← 3. An array of records stores a table: Bookings[5].Paid ← TRUE.
- Set: membership test, union, intersection, difference. No positions and no duplicates.
- Class: objects are created from it; data is usually private and changed through public methods.
Set operations (example)
With A = {2, 4, 6, 8} and B = {3, 6, 9}:
- Union A ∪ B = {2, 3, 4, 6, 8, 9}
- Intersection A ∩ B = {6}
- Difference A − B = {2, 4, 8}
- 4 is a member of A; 4 is not a member of B.
Choosing a type
| Clue in the question | Type |
|---|---|
| “One of the following options” | Enumerated |
| “Refers to / links to / address of” | Pointer |
| “Stores the following details about each …” | Record |
| “Check whether a value is one of …”, “items common to both” | Set |
| “Data and the operations on it”, “only changed by …” | Class |
Mini design
“Each parcel has a tracking code such as “TR00451”, a weight in kg and a service level that is Standard, Express or Overnight.”
TYPE TService = (Standard, Express, Overnight)
TYPE TParcel
DECLARE TrackingCode : STRING
DECLARE Weight : REAL
DECLARE Service : TService
ENDTYPE
Fixed list of options → enumerated; mixed details about one parcel → record; leading zeros and letters → STRING; weight with decimals → REAL.
Key terms
| Term | Meaning |
|---|---|
| User-defined data type | A type defined by the programmer, built from the built-in types |
| Non-composite type | A type holding a single value, not built from other types |
| Composite type | A type built from other types, holding several values |
| Enumerated type | A type defined by an ordered list of its possible values |
| Pointer type | A type whose variables hold memory addresses |
| Dereference | Access the value stored at the address held in a pointer |
| Set | An unordered collection of distinct values of one type |
| Object | An instance of a class |
Exam traps
- Enumerated values in quotation marks become strings: write Amber, not “Amber”.
- Ptr is an address; Ptr^ is a value. Mixing them is the commonest pointer error.
- Enumerated and pointer are non-composite; record, set and class are composite.
- A set has no order and no duplicates.
- A record definition needs a type for every field and ENDTYPE at the end.
- Justify a choice from the data: “fixed list of options”, “fields of different types”, “membership test”.
Self-test
- Give two reasons why user-defined types are necessary.
- Is a pointer type composite or non-composite?
- Define an enumerated type TSize with the values Small, Medium and Large.
- What does ^INTEGER mean in a type definition?
- Ptr holds the address of Score, which holds 12. What does Ptr^ ← Ptr^ * 3 do?
- Write a statement that sets the Paid field of the 4th element of the array Bookings to TRUE.
- With A = {1, 3, 5} and B = {3, 4, 5}, give A ∩ B and A ∪ B.
- Why is a set unsuitable for storing marks in the order they were entered?
- Name the composite type that combines data with its own methods.
- Which type suits a field that holds a suit of cards: Hearts, Clubs, Diamonds or Spades?
- Why are pointers needed for a linked list in dynamic memory?
- Why is a booking reference such as “H0047” a STRING field?
Answers: 1. Any two: models the problem’s data directly; restricts variables to valid values; groups related data into one unit; defined once and reused. 2. Non-composite. 3. TYPE TSize = (Small, Medium, Large) 4. The address of a value of type INTEGER. 5. It changes Score to 36. 6. Bookings[4].Paid ← TRUE 7. A ∩ B = {3, 5}; A ∪ B = {1, 3, 4, 5}. 8. A set has no order and cannot hold duplicate values. 9. A class. 10. An enumerated type. 11. Each node must hold the address of the next node, which may be anywhere in memory. 12. It contains a letter and must keep its leading zeros, and no arithmetic is done on it.
Related resources
-
Study guides
Cambridge A Level Computer Science (9618): File Organisation and Access
Study guide to 9618 section 13.2: serial, sequential and random files, sequential and direct access, choosing a method, and hashing algorithms.
Computer Science · Cambridge · A Level
Read guide -
Revision notes
Cambridge A Level Computer Science (9618): File Organisation and Access – Revision Notes
Revision notes for 9618 section 13.2: file organisations, access methods, hit rate, remainder and folding hashes, collisions, traps and a self-test.
Computer Science · Cambridge · A Level
Revise topic -
Study guides
Cambridge A Level Computer Science (9618): Floating-point Numbers, Representation and Manipulation
Study guide to 9618 section 13.3: floating-point format, converting to and from denary, normalisation, bit allocation, rounding, overflow and underflow.
Computer Science · Cambridge · A Level
Read guide
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.