Library › Computer Science 9618 › Data Types and Structures
AS Level · Computer Science 9618

Data Types and Structures

Revise Data Types and Structures for Computer Science 9618 (AS Level) — revision notes and instant AI marking.

📖 Revision notes · preview
  Cambridge International AS & A Level Computer Science (9618)

Data Types and Structures

The big idea: Choosing how to store data decides how easy it is to process. Pick the right type for each item, group related items into records, put many items into arrays or files, and know the three abstract data types (stack, queue, linked list) well enough to update them by hand.

Summary — What This Chapter Covers
  • Pseudocode data types: INTEGER, REAL, CHAR, STRING, BOOLEAN, DATE (plus ARRAY and FILE).
  • A record groups items of different data types under one identifier: TYPE … ENDTYPE.
  • Array terms: index, lower bound, upper bound. 1D and 2D arrays are declared with ARRAY[lower:upper] OF type.
  • Bubble sort repeatedly compares and swaps neighbours; linear search checks each element in turn.
  • Text files keep data after the program ends: OPENFILE, READFILE, WRITEFILE, EOF, CLOSEFILE.
  • An ADT is a collection of data plus a set of operations on it. Stack (LIFO), queue (FIFO) and linked list are ADTs.
  • Each ADT can be implemented using arrays with pointers.
1. Data Types
Data types and records

Choosing the right type

Choose the type that matches how the data is used.

TypeHoldsExample data
INTEGERA whole numberNumber of students, a year: 2026
REALA number with a fractional partPrice 4.75, temperature −2.5
CHARExactly one character, in single quotesGrade 'A', a gender code
STRINGZero or more characters, in double quotesName "Huda", a phone number "07912345678"
BOOLEANTRUE or FALSEIsMember, Paid
DATEA valid calendar dateDateOfBirth 02/01/2009

Telephone numbers, postcodes and ID codes with leading zeros are STRING: they are not used in calculations and a leading 0 would be lost as an INTEGER.

2. Records
Data types and records

Different types under one identifier

A record is a user-defined composite data type that holds several related items, of different data types, under one identifier. It keeps all the data about one thing together, so a whole record can be passed to a procedure, stored in an array, or written to a file as one unit.

TYPE BookRecord
   DECLARE ISBN : STRING
   DECLARE Title : STRING
   DECLARE Price : REAL
   DECLARE OnLoan : BOOLEAN
ENDTYPE

DECLARE Book : BookRecord
DECLARE Library : ARRAY[1:3] OF BookRecord

Book.ISBN ← "9780306406157"
Book.Title ← "Maths"
Book.Price ← 12.50
Book.OnLoan ← TRUE
Library[1] ← Book
Worked Example
Library[1..3] hold (Maths, 12.50, on loan), (Physics, 20.00, not on loan), (CS, 15.00, on loan). Write pseudocode to output the number of books on loan and their total value.
3. Arrays
Arrays

Index, bounds, 1D and 2D

An array is a fixed-size collection of elements of the same data type, under one identifier. Each element is accessed by its index (subscript). The lower bound is the index of the first element and the upper bound the index of the last. A 1D array suits a single list (the names in a class); a 2D array suits a table (marks for each student in each test), accessed as Array[row, column].

DECLARE Names : ARRAY[1:30] OF STRING
DECLARE Marks : ARRAY[1:3, 1:3] OF INTEGER
DECLARE Row, Column, RowTotal : INTEGER

FOR Row ← 1 TO 3
   RowTotal ← 0
   FOR Column ← 1 TO 3
      RowTotal ← RowTotal + Marks[Row, Column]
   NEXT Column
   OUTPUT "Student ", Row, " total: ", RowTotal
NEXT Row
Practice Question
4. Bubble Sort
Arrays
5. Linear Search
🔓 Read the full Data Types and Structures note → You're seeing the preview · sign in to read it all
Also in the full note
  • Compare neighbours, swap, repeat
  • Check each element in turn
  • Data that outlives the program
  • Data plus the operations on it
  • Pointers into arrays
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise Data Types and Structures with Computer Science 9618 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full Data Types and Structures notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics