0% found this document useful (0 votes)
4 views

CS Notes

The AS-Level Computer Science (9618) Revision Notes for the 2024-2025 syllabus cover essential topics such as information representation, communication, hardware, processor fundamentals, and system software. Each section is detailed with subtopics including data representation, network types, CPU architecture, and operating systems. The document serves as a comprehensive guide for students preparing for their exams.

Uploaded by

matikhgz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CS Notes

The AS-Level Computer Science (9618) Revision Notes for the 2024-2025 syllabus cover essential topics such as information representation, communication, hardware, processor fundamentals, and system software. Each section is detailed with subtopics including data representation, network types, CPU architecture, and operating systems. The document serves as a comprehensive guide for students preparing for their exams.

Uploaded by

matikhgz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

AS-Level Computer Science (9618) Revision Notes

(Syllabus 2024-2025)

Generated based on Syllabus and Textbook Extract

April 5, 2025

Contents
1 Information Representation 6
1.1 Data Representation (1.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.1 Number Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.2 Binary Prefixes vs Decimal Prefixes . . . . . . . . . . . . . . . . . . . . . . 6
1.1.3 Representing Negative Integers . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.4 Binary Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.5 Character Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2 Multimedia (1.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.2 Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 Compression (1.3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 Communication 11
2.1 Networks including the internet (2.1) . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Network Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.2 Network Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.3 Thin vs. Thick Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.4 Network Topologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.5 Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.6 Wired vs. Wireless Networking . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.7 Networking Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.8 Ethernet and CSMA/CD . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.9 Bit Streaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.10 Internet vs. World Wide Web (WWW) . . . . . . . . . . . . . . . . . . . 15
2.1.11 Internet Connectivity Hardware . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.12 IP Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.13 URL and DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3 Hardware 17
3.1 Computers and their components (3.1) . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.1 Basic Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2 Embedded Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.3 Hardware Device Operations . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.4 Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.5 Memory Types (RAM/ROM) . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.6 Monitoring and Control Systems . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Logic Gates and Logic Circuits (3.2) . . . . . . . . . . . . . . . . . . . . . . . . . 19

1
3.2.1 Logic Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2.2 Logic Circuits and Truth Tables . . . . . . . . . . . . . . . . . . . . . . . 20

4 Processor Fundamentals 22
4.1 Central Processing Unit (CPU) Architecture (4.1) . . . . . . . . . . . . . . . . . . 22
4.1.1 Von Neumann Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.1.2 CPU Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.1.3 System Buses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.4 Factors Affecting Performance . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.5 Computer Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.6 Fetch-Execute Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.1.7 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 Assembly Language (4.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.1 Relationship to Machine Code . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.2 Two-Pass Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.3 Instruction Set (Example - based on syllabus) . . . . . . . . . . . . . . . . 26
4.2.4 Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3 Bit manipulation (4.3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.1 Binary Shifts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.2 Using Bit Manipulation for Monitoring/Control . . . . . . . . . . . . . . . 27

5 System Software 29
5.1 Operating Systems (5.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1.1 Need for an Operating System (OS) . . . . . . . . . . . . . . . . . . . . . 29
5.1.2 Key Management Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1.3 Utility Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1.4 Program Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2 Language Translators (5.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2.1 Types of Translators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2.2 Compiler vs. Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.3 Partial Compilation/Interpretation (Bytecode) . . . . . . . . . . . . . . . 31
5.2.4 Integrated Development Environment (IDE) . . . . . . . . . . . . . . . . . 31

6 Security, Privacy and Data Integrity 33


6.1 Data Security (6.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.1.1 Security, Privacy, Integrity Definitions . . . . . . . . . . . . . . . . . . . . 33
6.1.2 Need for Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.1.3 Security Measures (System and Data) . . . . . . . . . . . . . . . . . . . . 33
6.1.4 Threats (Network/Internet) . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.1.5 Restricting Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2 Data Integrity (6.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2.1 Data Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2.2 Data Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

7 Ethics and Ownership 36


7.1 Ethics and Ownership (7.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.1 Ethics in Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.2 Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.3 Software Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.4 Artificial Intelligence (AI) . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

2
8 Databases 38
8.1 Database Concepts (8.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.1.1 File-Based Approach Limitations . . . . . . . . . . . . . . . . . . . . . . . 38
8.1.2 Relational Database Features . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.1.3 Relational Database Terminology . . . . . . . . . . . . . . . . . . . . . . . 38
8.1.4 Entity-Relationship (E-R) Diagrams . . . . . . . . . . . . . . . . . . . . . 39
8.1.5 Normalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 Database Management Systems (DBMS) (8.2) . . . . . . . . . . . . . . . . . . . . 40
8.2.1 DBMS Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.2.2 DBMS Software Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.3 Data Definition Language (DDL) and Data Manipulation Language (DML) (8.3) 41
8.3.1 Roles of DDL and DML . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.3.2 SQL (DDL) Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.3.3 SQL (DML) Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

9 Algorithm Design and Problem-solving 43


9.1 Computational Thinking Skills (9.1) . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.1.1 Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.1.2 Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2 Algorithms (9.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2.1 Algorithm Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2.2 Basic Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2.3 Algorithm Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.2.4 Writing and Drawing Algorithms . . . . . . . . . . . . . . . . . . . . . . . 44
9.2.5 Stepwise Refinement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.2.6 Logic Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

10 Data Types and Structures 45


10.1 Data Types and Records (10.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.1.1 Basic Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.1.2 Record Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.2 Arrays (10.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.2.1 Array Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.2.2 1D Arrays (Lists) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.2.3 2D Arrays (Tables) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.2.4 Processing Array Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.3 Files (10.3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.3.1 Need for Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.3.2 Handling Text Files (Pseudocode) . . . . . . . . . . . . . . . . . . . . . . 47
10.4 Introduction to Abstract Data Types (ADT) (10.4) . . . . . . . . . . . . . . . . . 47
10.4.1 ADT Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.4.2 Examples of ADTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.4.3 Using ADTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.4.4 Array Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

11 Programming 49
11.1 Programming Basics (11.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.1.1 Implementing Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.1.2 Pseudocode Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.1.3 Built-in Functions and Library Routines . . . . . . . . . . . . . . . . . . . 49
11.2 Constructs (11.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.2.1 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

3
11.2.2 Iteration (Loops) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.2.3 Justifying Loop Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
11.3 Structured Programming (11.3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
11.3.1 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
11.3.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
11.3.3 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
11.3.4 Efficient Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

12 Software Development 53
12.1 Program Development Life cycle (12.1) . . . . . . . . . . . . . . . . . . . . . . . . 53
12.1.1 Purpose of a Development Life Cycle . . . . . . . . . . . . . . . . . . . . . 53
12.1.2 Different Development Life Cycles . . . . . . . . . . . . . . . . . . . . . . 53
12.1.3 Stages in the Program Development Life Cycle . . . . . . . . . . . . . . . 53
12.2 Program Design (12.2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12.2.1 Structure Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12.2.2 State-Transition Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12.3 Program Testing and Maintenance (12.3) . . . . . . . . . . . . . . . . . . . . . . . 55
12.3.1 Exposing and Avoiding Faults . . . . . . . . . . . . . . . . . . . . . . . . . 55
12.3.2 Types of Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
12.3.3 Testing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
12.3.4 Test Strategy and Test Plan . . . . . . . . . . . . . . . . . . . . . . . . . . 56
12.3.5 Test Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
12.3.6 Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
12.3.7 Analysing and Amending Existing Programs . . . . . . . . . . . . . . . . . 56

4
Key Concepts
These are essential ideas underpinning the AS Level Computer Science course.

• Computational thinking: A set of fundamental skills (abstraction, decomposition, algo-


rithmic thinking) used to study problems and design implementable solutions, potentially
using various technologies and programming languages.

• Programming paradigms: Different ways of thinking about or approaching problems


using various programming styles suited to unique functions, tools, and situations. Under-
standing paradigms is crucial for appropriate use in designing and building programs.

• Communication: A core requirement involving data transfer between devices/compo-


nents, understanding the rules and methods used (protocols). This ranges from internal
data transfer to internet-scale communication.

• Computer architecture and hardware: The design of a computer system’s internal


operation, including how components and data are organised and communicated. Different
architectures suit different scenarios. Hardware components (CPU, memory, peripherals)
work together, enabled by software, to perform tasks and allow user interaction.

• Data representation and structures: Computers use binary. Understanding how bi-
nary numbers are interpreted in various ways is crucial. Programming requires knowledge
of how data can be organised (data structures) for efficient access and transfer.

Syllabus Aims
The course aims to enable students to develop:

• computational thinking skills.

• an understanding of the main principles of solving problems using computers.

• an understanding of the component parts of computer systems and how they interrelate
(software, data, hardware, communication, people).

• an understanding of different communication methods and the functionality of networks


and the internet.

• the skills to apply this understanding to develop computer-based solutions to problems.

5
1 Information Representation
1.1 Data Representation (1.1)
1.1.1 Number Systems
• Denary (Base 10): Uses digits 0-9. Standard human number system.

• Binary (Base 2): Uses digits 0 and 1 (bits). Fundamental system for computers (ON/OFF
switches). Column weights are powers of 2 (..., 128, 64, 32, 16, 8, 4, 2, 1).

• Hexadecimal (Base 16): Uses digits 0-9 and letters A-F (A=10, B=11, C=12, D=13,
E=14, F=15). Column weights are powers of 16 (..., 4096, 256, 16, 1). Used as a shorthand
for binary as 1 hex digit represents 4 bits (16 = 24 ).

• Binary Coded Decimal (BCD): Each denary digit is represented by a 4-bit binary
code. E.g., 3165 in BCD is 0011 0001 0110 0101. Used where exact decimal representation
is vital (e.g., finance, calculators, clocks).

Conversions:

• Binary to Denary: Sum the column values where a ’1’ appears. E.g., 111011102 =
128 + 64 + 32 + 8 + 4 + 2 = 23810 .

• Denary to Binary (Method 1 - Place Value): Place 1s in appropriate columns to


sum to the denary value. E.g., 10710 = 64 + 32 + 8 + 2 + 1 = 011010112 .

• Denary to Binary (Method 2 - Successive Division): Repeatedly divide the denary


number by 2, recording remainders. Read remainders bottom-up.

• Binary to Hexadecimal: Group binary digits into sets of 4 from right to left (padding
with leading zeros if needed). Convert each 4-bit group to its hex equivalent. E.g.,
1011111000012 → 1011 1110 0001 → BE116 .

• Hexadecimal to Binary: Convert each hex digit to its 4-bit binary equivalent. E.g.,
45A16 → 0100 0101 1010 → 0100010110102 .

• Hexadecimal to Denary: Multiply each hex digit by its corresponding power of 16 and
sum the results. E.g., BE116 = (11×162 )+(14×161 )+(1×160 ) = 2816+224+1 = 304110 .

• Denary to Hexadecimal: Use successive division by 16, converting remainders > 9 to


A-F. Read remainders bottom-up.

Applications of Hexadecimal and BCD:

• Hexadecimal: Memory dumps (easier for humans to read than binary), MAC addresses,
assembly language, defining colours in HTML/CSS (e.g., #FF0000 for red).

• BCD: Calculators, digital clocks, financial systems requiring exact decimal arithmetic
(avoids binary floating-point rounding errors).

1.1.2 Binary Prefixes vs Decimal Prefixes


Computers measure storage in powers of 2, while the SI system uses powers of 10. This leads to
two sets of prefixes:

6
Binary (IEC) Decimal (SI)
Prefix Symbol Value (Bytes) Prefix Symbol Value (Bytes)
kibi Ki 210 = 1024 kilo k 103 = 1000
mebi Mi 20
2 = 1, 048, 576 mega M 106 = 1, 000, 000
gibi Gi 2 = 1, 073, 741, 824 giga
30 G 109 = 1, 000, 000, 000
tebi Ti 240 ≈ 1.10 × 1012 tera T 1012 = 1, 000, 000, 000, 000
pebi Pi 50
2 ≈ 1.13 × 10 15 peta P 1015
Note: Internal memory (RAM) is typically measured using binary prefixes (KiB, MiB, GiB).
Storage devices (HDDs, SSDs) often use decimal prefixes (KB, MB, GB, TB), which can seem
misleadingly large compared to binary measurements.

1.1.3 Representing Negative Integers


• Sign and Magnitude: The Most Significant Bit (MSB) indicates the sign (0 for posi-
tive, 1 for negative). The remaining bits represent the magnitude. Has issues with two
representations of zero (+0 and -0) and complex arithmetic. (Not explicitly required by
syllabus notes but useful context).

• Two’s Complement: The standard method. To find the negative of a binary number:

1. Invert all the bits (0s become 1s, 1s become 0s - this is One’s Complement).
2. Add 1 to the result.

For an 8-bit number, the MSB has a weight of -128. The range is -128 to +127. E.g., To
represent -90 (using 8 bits):

– +90 = 010110102
– Invert: 101001012
– Add 1: 101001102 = −9010 (Check: −128 + 32 + 8 + 4 + 2 = −90)

1.1.4 Binary Arithmetic


• Addition: Follow standard binary addition rules (0+0=0, 0+1=1, 1+0=1, 1+1=0 carry
1, 1+1+1=1 carry 1).

• Subtraction: Convert the number being subtracted into its two’s complement negative
equivalent, then perform binary addition. Discard any carry bit beyond the original number
of bits. E.g., 95 − 68 (using 8 bits):

– 95 = 010111112
– 68 = 010001002
– −68 (Two’s Complement): Invert 01000100 → 10111011, Add 1 → 101111002
– Add:
0101111
1
+ 1011110
0
(1) 0001101
1
– Result (discarding carry): 000110112 = 16 + 8 + 2 + 1 = 2710 .

7
• Overflow: Occurs when the result of an arithmetic operation exceeds the range repre-
sentable by the number of bits used.

– Adding two positive numbers gives a negative result.


– Adding two negative numbers gives a positive result.
– Subtracting a positive number from a negative number gives a positive result.
– Subtracting a negative number from a positive number gives a negative result.

E.g., 82 + 69 (using 8 bits):

– 82 = 010100102
– 69 = 010001012
– Add:
0101001
0
+ 0100010
1
1001011
1
– Result: 100101112 = −10510 . This is incorrect (should be 151). Overflow occurred
because 151 is outside the 8-bit two’s complement range (-128 to +127).

1.1.5 Character Representation


Computers store characters using binary codes defined by character sets.

• ASCII (American Standard Code for Information Interchange): Originally a 7-bit


code (128 characters), representing uppercase/lowercase letters, digits, punctuation, and
control codes.

• Extended ASCII: An 8-bit code (256 characters), adding graphics symbols and foreign
language characters. Not fully standardised.

• Unicode: A universal character encoding standard designed to represent characters from


almost all writing systems. Uses variable-width encoding (e.g., UTF-8, UTF-16, UTF-32),
commonly using 16 or 32 bits per character. The first 128 characters match ASCII for
compatibility.

Note: Students are expected to be familiar with these concepts but not memorise specific char-
acter codes.

1.2 Multimedia (1.2)


1.2.1 Graphics
Bitmap Images:

• Composed of a grid of individual picture elements called pixels.

• Stored as a 2D array/matrix of pixels.

• Image Resolution: The total number of pixels in an image (width x height).

• Screen Resolution: The number of pixels a display device can show (width x height). If
image resolution > screen resolution, the image must be resized or cropped.

8
• Colour Depth / Bit Depth: The number of bits used to represent the colour of a single
pixel.

– 1-bit: Monochrome (2 colours)


– 8-bit: 256 colours
– 16-bit: 65,536 colours (High Colour)
– 24-bit: 16,777,216 colours (True Colour)

• File Header: Stores metadata about the image, such as file type (e.g., BMP, JPEG, GIF,
PNG), image resolution, colour depth, compression method (if any).

• File Size Calculation (Uncompressed): File Size (bits) = Image Width (pixels) ×
Image Height (pixels) × Colour Depth (bits per pixel) File Size (bytes) = File Size (bits)
/8

• Effects of Changing Elements:

– Increasing resolution or colour depth increases file size and potentially image quality
(up to a point).
– Decreasing resolution or colour depth decreases file size and image quality.

Vector Graphics:

• Images defined using mathematical descriptions of geometric shapes (lines, curves, poly-
gons).

• Objects are described by their properties (e.g., coordinates, line colour, fill colour, line
thickness).

• Stored as a drawing list containing commands and properties for each object.

• Scalability: Can be scaled to any size without loss of quality (pixels are recalculated based
on the mathematical description).

• File Size: Generally smaller than bitmaps for images composed of geometric shapes (like
logos, diagrams), but can be larger for complex photographic-style images.

• Editing: Objects can be edited individually (moved, resized, colour changed).

• Common formats: SVG, CGM, ODG, AI, EPS.

Bitmap vs. Vector Justification:

• Use Bitmap for: Photographic images, complex images with subtle colour variations.
When pixel-level editing is needed.

• Use Vector for: Logos, diagrams, illustrations, text. When scalability is important. When
file size needs to be small for simple graphics.

1.2.2 Sound
• Sound is an analogue wave (continuous variation in air pressure).

• Computers store sound as digital data.

• Conversion from analogue to digital is done by an Analogue-to-Digital Converter (ADC),


often on a sound card.

9
• Sampling: The process of taking measurements of the analogue signal’s amplitude at
regular time intervals.
• Sampling Rate: The number of samples taken per second (measured in Hertz, Hz).
Higher sampling rate = more accurate representation of the original sound, larger file size.
(e.g., CD quality is 44.1 kHz).
• Sampling Resolution / Bit Depth: The number of bits used to store the value of each
sample’s amplitude. Higher resolution = more accurate amplitude representation, wider
dynamic range, larger file size. (e.g., CD quality is 16-bit).
• File Size Calculation (Uncompressed): File Size (bits) = Sampling Rate (Hz) ×
Sampling Resolution (bits) × Duration (seconds) × [Number of Channels (e.g., 1 for mono,
2 for stereo)]
• Impact of Changing Rate/Resolution: Increasing sampling rate or resolution improves
accuracy/quality but increases file size. Decreasing them reduces file size but lowers quality.

1.3 Compression (1.3)


Need for Compression:
• Reduce file sizes for storage (save disk space).
• Reduce file sizes for faster transmission over networks/internet (reduce download/upload
times, save bandwidth).
Types of Compression:
• Lossless Compression: Reduces file size without discarding any original data. The
original file can be perfectly reconstructed upon decompression. Used when data integrity
is crucial (e.g., text files, program code, some image formats like PNG, GIF).
• Lossy Compression: Reduces file size by permanently discarding some data deemed less
important or imperceptible to humans. Achieves much higher compression ratios than
lossless. Original file cannot be perfectly reconstructed. Used for multimedia files where
some quality loss is acceptable (e.g., JPEG images, MP3/AAC audio, MPEG video).
Justification:
• Use Lossless when: Every bit of data must be preserved (text documents, spreadsheets,
source code, medical images).
• Use Lossy when: High compression is needed and some quality loss is acceptable (pho-
tographs for web use, streaming audio/video).
Compression Techniques:
• Run-Length Encoding (RLE): A simple lossless technique. Replaces sequences (runs)
of identical data values with a count of the repetitions and a single instance of the value.
– Text Example: "AAAAABBBCCDDDDD" becomes "5A3B2C5D".
– Image Example (Bitmap): A row of pixels ‘WWWWBBW‘ (W=White, B=Black)
could become ‘4W2B1W‘. Effective for images with large areas of solid colour.
• Other methods (awareness): JPEG uses techniques like Discrete Cosine Transform
(DCT) and quantization. MP3 uses perceptual coding (removing sounds humans can’t
easily hear). Vector graphics can be compressed as they are often stored in text-based
formats (like SVG which uses XML) that compress well using standard text compression
algorithms (like ZIP).

10
2 Communication
2.1 Networks including the internet (2.1)
2.1.1 Network Types
• LAN (Local Area Network): Covers a small geographical area (e.g., single building,
school campus). Typically owned by the organisation using it. High data transfer rates.
Usually uses technologies like Ethernet (wired) or Wi-Fi (wireless).

• WAN (Wide Area Network): Covers a large geographical area (e.g., country, continent,
globe). Often uses infrastructure leased from telecommunications companies (e.g., fibre
optic cables, satellite links). The Internet is the largest WAN. Slower data transfer rates
than LANs.

• MAN (Metropolitan Area Network): Spans a city or large campus. Larger than
LAN, smaller than WAN. (Less common term).

• WLAN (Wireless Local Area Network): A LAN that uses wireless communication
(Wi-Fi) instead of cables.

• PAN (Personal Area Network): Centred around an individual’s workspace, connecting


devices like laptops, smartphones, printers over short distances (e.g., Bluetooth).

2.1.2 Network Models


• Client-Server Model:

– Uses dedicated servers to provide resources (files, printing, email, web pages) and
clients (workstations) that request those resources.
– Centralised administration and security (user accounts, access rights managed on
server).
– Easier to manage backups and updates.
– Scalable to large numbers of users.
– Server failure can disrupt network services. Server can become a bottleneck.
– Examples: School networks, corporate networks, web servers.

• Peer-to-Peer (P2P) Model:

– All computers (peers) have equal status; they can both provide and request resources.
– No central server. Each computer manages its own security and resources.
– Simpler to set up for small networks.
– Less secure and harder to manage backups and administration as network grows.
– Performance can degrade if many peers access one particular peer.
– Examples: Small home networks, file-sharing systems (like BitTorrent, though these
often use trackers which add a client-server element).

Justification: Client-server is better for larger networks needing central control and security.
P2P is simpler and cheaper for small, informal networks.

11
2.1.3 Thin vs. Thick Clients
Refers to client devices, primarily in a client-server model.

• Thick Client: A standard PC/laptop capable of significant processing and storage lo-
cally. Can perform many tasks independently of the server, even if offline. Requires more
local maintenance (updates, security). Example: A standard desktop computer running
applications locally but accessing files from a server.

• Thin Client: A low-spec device (or software) heavily dependent on a server for processing
and storage. Often has minimal local storage and OS. Primarily acts as an input/output
terminal for the server. Cheaper hardware, easier central management, requires constant
network connection. Example: A terminal in a library accessing a remote catalogue, a web
browser accessing a complex web application.

2.1.4 Network Topologies


The physical or logical arrangement of devices in a network.

• Bus Topology:

– All devices connect to a single central cable (the bus).


– Terminators are needed at each end to prevent signal reflection.
– Simple and cheap to install.
– Bus failure disables the entire network segment.
– Performance degrades under heavy load (only one device can transmit at a time).
– Collisions occur if multiple devices transmit simultaneously.
– Data is broadcast to all nodes, raising security concerns.
– Packet Transmission: Sent along the bus, all nodes receive it, only the destination
node processes it.

• Star Topology:

– All devices connect to a central point (hub or switch).


– Most common topology for LANs today.
– Failure of a single cable/device (except the central point) doesn’t affect others.
– Central point failure disables the network.
– Easy to add/remove devices and troubleshoot.
– Performance depends on the central device (switch is better than hub).
– More expensive due to cabling and central device cost.
– Packet Transmission (Switch): Switch directs packet only to the destination port.
– Packet Transmission (Hub): Hub broadcasts packet to all ports (like a bus).

• Mesh Topology:

– Devices are interconnected, often with multiple paths between nodes (full or partial
mesh).
– Highly reliable and fault-tolerant (multiple paths available if one fails).
– Complex and expensive to install and manage due to extensive cabling.
– Used in WANs and the internet backbone for resilience.

12
– Packet Transmission: Routers determine the best path for packets.

• Hybrid Topology: A combination of two or more topologies (e.g., star-bus).

Justification: Star is common for LANs due to ease of management and reasonable reliability.
Bus is older and less reliable/performant. Mesh offers high reliability for critical networks like
WAN backbones.

2.1.5 Cloud Computing


Delivery of computing services (servers, storage, databases, networking, software, analytics, in-
telligence) over the Internet (“the cloud”).

• Public Cloud: Services offered over the public internet, available to anyone. Provider
owns and manages the infrastructure. (e.g., AWS, Google Cloud, Microsoft Azure).

• Private Cloud: Cloud infrastructure operated solely for a single organization. Can be
managed internally or by a third party, hosted internally or externally. Offers more control
and security.

• Benefits: Scalability, cost savings (pay-as-you-go), accessibility (from anywhere), reliabil-


ity (often redundant infrastructure), automatic updates.

• Drawbacks: Requires internet connectivity, potential security/privacy concerns (data held


by third party), potential vendor lock-in, costs can escalate if usage is high.

2.1.6 Wired vs. Wireless Networking


• Wired Media:

– Copper Cable (e.g., Twisted Pair): Most common for LANs (Ethernet). Rel-
atively inexpensive. Susceptible to electromagnetic interference (EMI). Limited dis-
tance. Types: UTP (Unshielded), STP (Shielded).
– Coaxial Cable: Used for cable TV and older networks. More resistant to EMI than
UTP. More expensive than twisted pair.
– Fibre Optic Cable: Transmits data as pulses of light. Very high bandwidth and
data rates. Immune to EMI. Can span long distances. Secure (hard to tap). Expensive
and requires specialist installation.

• Wireless Media:

– Radio Waves (e.g., Wi-Fi - IEEE 802.11 standards): Uses specific frequency
bands (e.g., 2.4 GHz, 5 GHz). Convenient, allows mobility. Susceptible to interference,
obstacles (walls), and security threats (needs encryption like WPA2/WPA3). Range
depends on standard and environment.
– Microwaves: High frequency radio waves. Used for point-to-point links, satellite
communication. Requires line-of-sight. Can be affected by weather.
– Satellites: Used for long-distance communication (WANs, broadcasting, GPS). Geo-
stationary (GEO), Medium Earth Orbit (MEO), Low Earth Orbit (LEO) satellites
offer different coverage and latency characteristics.

• Implications: Wired generally offers higher speed, reliability, and security but less mo-
bility. Wireless offers convenience and mobility but potentially lower speed, reliability, and
security. Choice depends on needs (cost, speed, distance, mobility, security).

13
2.1.7 Networking Hardware
• Switch: Connects devices in a LAN (typically star topology). Reads destination MAC ad-
dresses to forward packets only to the intended recipient port. Reduces collisions compared
to hubs.
• Router: Connects different networks together (e.g., LAN to WAN, LAN to Internet).
Works with IP addresses to determine the best path for packets between networks. Can
perform Network Address Translation (NAT).
• Server: A computer providing resources/services to clients (file server, web server, print
server, email server).
• Network Interface Card (NIC) / Wireless NIC (WNIC): Hardware allowing a
device to connect to a wired (NIC) or wireless (WNIC) network. Contains the unique
MAC address.
• Wireless Access Point (WAP): Allows wireless devices to connect to a wired network.
Acts as a central point for Wi-Fi communication. Often integrated into routers.
• Cables: Physical media (Twisted Pair, Coaxial, Fibre Optic) used in wired networks.
• Bridge: Connects two LAN segments using the same protocol. Operates at the Data
Link layer, filtering traffic based on MAC addresses to reduce unnecessary traffic between
segments. Less common now, largely replaced by switches.
• Repeater: Regenerates and retransmits signals to extend network range (combats signal
attenuation). Operates at the Physical layer. Used in both wired and wireless networks.
(Hubs often act as multi-port repeaters).
• Modem (Modulator/Demodulator): Converts digital signals from a computer to ana-
logue signals for transmission over analogue lines (like traditional phone lines - PSTN) and
vice versa. Needed for technologies like DSL.

2.1.8 Ethernet and CSMA/CD


• Ethernet: A family of wired LAN technologies (IEEE 802.3 standards), defining physical
layer and data link layer protocols. Uses MAC addresses for device identification.
• Collision Domain: A network segment where data packets can collide if multiple devices
transmit simultaneously (common in bus topology or networks using hubs). Switches create
separate collision domains per port.
• CSMA/CD (Carrier Sense Multiple Access with Collision Detection): Protocol
used in older (hub-based) Ethernet networks to manage shared media access.
1. Carrier Sense: Listen to the medium; if idle, transmit. If busy, wait.
2. Multiple Access: Multiple devices share the same medium.
3. Collision Detection: While transmitting, listen for collisions (detected by signal
strength changes). If a collision occurs:
– Stop transmitting immediately.
– Transmit a "jam signal" to ensure all other nodes detect the collision.
– Wait a random amount of time (backoff algorithm).
– Attempt to retransmit (go back to step 1).
Note: CSMA/CD is largely obsolete in modern switched networks where full-duplex com-
munication eliminates collisions.

14
2.1.9 Bit Streaming
Continuous transmission of digital data, often for multimedia.

• Methods:

– Real-time Streaming: Data is broadcast live as it’s captured (e.g., live video broad-
cast, online radio). User cannot pause/rewind beyond a small buffer. Requires con-
sistent bandwidth.
– On-demand Streaming: Data is stored on a server and streamed when requested
by the user (e.g., Netflix, YouTube, Spotify). User can typically pause, rewind, fast-
forward. Requires sufficient bandwidth for playback speed.

• Buffering: Temporarily storing streamed data locally before playback. Smooths out vari-
ations in network speed, preventing playback interruptions. Requires sufficient buffer size
and download speed > playback speed.

• Bit Rates: The amount of data transmitted per second (e.g., kbps, Mbps). Higher bit
rates generally mean higher quality (for lossy compression) but require more bandwidth.
Broadband speeds are crucial for smooth streaming, especially for high-definition video.

2.1.10 Internet vs. World Wide Web (WWW)


• Internet: The global network infrastructure connecting millions of computers and net-
works using the TCP/IP protocol suite. It’s the hardware and network connections.

• World Wide Web (WWW): A service/system running *on* the Internet. It’s a collec-
tion of interlinked documents (web pages) and resources accessed via URLs using protocols
like HTTP/HTTPS. It’s the information accessed *via* the Internet infrastructure. You
use the Internet to access the WWW.

2.1.11 Internet Connectivity Hardware


• Modem: Connects home network to ISP (e.g., via DSL, cable, fibre).

• PSTN (Public Switched Telephone Network): Traditional analogue phone lines,


used for dial-up and DSL.

• Dedicated Lines: Leased lines providing permanent connection, often used by businesses.
More reliable and expensive than standard broadband.

• Cell Phone Network: Mobile data networks (3G, 4G, 5G) providing internet access to
mobile devices.

2.1.12 IP Addressing
Unique numerical label assigned to each device participating in a computer network that uses
the Internet Protocol for communication.

• IPv4 (Internet Protocol version 4):

– 32-bit address, written as four 8-bit numbers (0-255) separated by dots (e.g., 192.168.1.1).
– Address space nearly exhausted (≈ 4.3 billion addresses).

• IPv6 (Internet Protocol version 6):

15
– 128-bit address, written as eight groups of four hexadecimal digits separated by colons
(e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
– Vastly larger address space.
– Can be shortened using techniques like zero compression (replacing consecutive
groups of zeros with ‘::‘, used only once per address) and omitting leading zeros in a
group.

• Subnetting: Dividing a larger network into smaller sub-networks (subnets). Improves


organisation, security, and efficiency by using a subnet mask to differentiate network/sub-
net/host portions of an IP address.

• Public IP Address: Globally unique address assigned by an ISP, directly reachable from
the internet.

• Private IP Address: Address used within a private network (behind a router/NAT).


Not reachable directly from the internet. Common ranges: 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16. Network Address Translation (NAT) on the router maps private IPs to
the single public IP for internet access.

• Static IP Address: Fixed IP address manually assigned to a device. Doesn’t change.


Often used for servers.

• Dynamic IP Address: IP address automatically assigned to a device (usually by a DHCP


server) for a limited period. More common for client devices.

2.1.13 URL and DNS


• URL (Uniform Resource Locator): An address used to locate a resource on the
WWW (e.g., web page, image). Structure: protocol://domain-name/path/filename
(e.g., https://www.cambridgeinternational.org/programmes-and-qualifications/).

• DNS (Domain Name System/Service): A hierarchical and distributed naming system


that translates human-readable domain names (e.g., ‘www.cambridgeinternational.org‘)
into machine-readable IP addresses (e.g., ‘104.22.6.109‘). Essential for navigating the web
using names instead of numbers.

– Process: When you type a URL, your computer queries a DNS server. If the server
doesn’t know the IP, it queries other DNS servers up the hierarchy until the IP address
is found or determined not to exist. The IP is returned to your computer, which then
connects to the web server at that IP address. DNS results are often cached locally
or by ISPs to speed up future lookups.

16
3 Hardware
3.1 Computers and their components (3.1)
3.1.1 Basic Components
Computers require:

• Input Devices: To get data into the system (e.g., keyboard, mouse, microphone, sensor).

• Output Devices: To present results to the user (e.g., monitor, printer, speakers, actua-
tor).

• Processor (CPU): To execute instructions and process data.

• Primary Memory (Main Memory - RAM/ROM): To hold data and instructions


currently being used by the CPU. Fast access, volatile (RAM) or non-volatile (ROM).

• Secondary Storage: To store data and programs long-term when not in use. Slower
access than primary memory, non-volatile (e.g., HDD, SSD, optical discs, flash drives).
Includes removable storage for transfer/backup.

3.1.2 Embedded Systems


• A computer system (microprocessor, memory, I/O interfaces) designed for a specific func-
tion within a larger mechanical or electrical system.

• Often performs a dedicated task (e.g., controlling a washing machine, microwave oven,
engine management system, medical device).

• Benefits: Often smaller, cheaper, more power-efficient, more reliable (dedicated task),
real-time response possible.

• Drawbacks: Difficult to upgrade, limited functionality, troubleshooting can be specialised.

3.1.3 Hardware Device Operations


• Laser Printer: Uses static electricity and powdered ink (toner). A laser beam neutralises
charge on a rotating drum corresponding to the image. Toner sticks to charged areas,
transfers to paper, and is fused by heat. Prints whole page at once.

• 3D Printer: Creates physical objects layer by layer from a digital model. Methods include:

– Direct: Print head moves in X, Y, Z, extruding melted material (like FDM/FFF).


– Binder: Sprays powder layer, then binder agent to solidify shape.
– Others use lasers/UV light to cure liquid resin (SLA/DLP) or sinter powder (SLS).

• Microphone: Converts sound waves into electrical (analogue) signals using a diaphragm
and coil/magnet or capacitor. Requires ADC for digital storage/processing.

• Speakers: Converts electrical (analogue) signals into sound waves using an electromagnet,
coil, and cone. Requires DAC for playback of digital audio.

• Magnetic Hard Disk Drive (HDD): Stores data magnetically on rotating platters
coated with magnetic material. Read/write heads move across platters. Data stored in
tracks and sectors. Suffers from latency (rotational delay + seek time). Susceptible to
physical shock.

17
• Solid State Drive (SSD): Stores data electronically using flash memory (NAND or
NOR chips). No moving parts. Faster access times (no latency), more durable, lower
power consumption, quieter than HDDs. More expensive per GB (historically). Limited
write endurance (though improving).

• Optical Disc Reader/Writer (CD/DVD/Blu-ray): Uses laser light to read/write


data on spinning discs. Data stored as pits and lands on a spiral track. Different laser
wavelengths/disc structures allow varying capacities (CD < DVD < Blu-ray). Dual layering
increases capacity.

• Touchscreen: Input/output device allowing interaction via touch. Types:

– Resistive: Two flexible layers separated by a gap. Pressure completes a circuit at


the touch point. Can use finger, stylus, gloved hand. Less durable, poorer visibility.
– Capacitive: Glass layers form a capacitor. Finger touch disrupts the electric field;
location is calculated. Requires conductive touch (bare finger, special stylus). More
durable, better visibility, supports multi-touch.

• Virtual Reality (VR) Headset: Worn on the head, covers eyes. Displays stereoscopic
images (one per eye) via screens (LCD/OLED) and lenses to create immersive 3D effect.
Uses sensors (gyroscopes, accelerometers, external tracking) to monitor head movement
and update view accordingly. Often includes integrated audio.

3.1.4 Buffers
Temporary storage area used to hold data being transferred between devices or processes oper-
ating at different speeds. Helps prevent data loss and smooths out data flow (e.g., printer buffer,
streaming buffer, keyboard buffer).

3.1.5 Memory Types (RAM/ROM)


• RAM (Random Access Memory):

– Read/write capability.
– Volatile (data lost when power off).
– Holds OS, running applications, data currently in use.
– Types: DRAM, SRAM.

• ROM (Read Only Memory):

– Read-only (contents cannot normally be changed by user).


– Non-volatile (data retained when power off).
– Holds essential startup instructions (e.g., BIOS/UEFI bootstrap loader).

• DRAM (Dynamic RAM):

– Uses capacitors and transistors.


– Requires constant refreshing to maintain data.
– Slower, cheaper, higher density than SRAM.
– Used for main system memory.

• SRAM (Static RAM):

– Uses flip-flops (latches).

18
– Does not require refreshing.
– Faster, more expensive, lower density than DRAM.
– Used for CPU cache memory.

• PROM (Programmable ROM): Can be written to once by the user/manufacturer.

• EPROM (Erasable Programmable ROM): Can be erased (using UV light) and re-
programmed multiple times. Has a quartz window.

• EEPROM (Electrically Erasable Programmable ROM): Can be erased and repro-


grammed electrically, multiple times, without removal from the circuit. Flash memory is a
type of EEPROM.

3.1.6 Monitoring and Control Systems


• Monitoring System: Reads data from sensors but does not actively change the environ-
ment. May trigger alarms or log data. Example: Burglar alarm detecting motion, weather
station recording temperature.

• Control System: Reads data from sensors and uses it to make decisions and adjust
actuators to modify the environment, often aiming to maintain a desired state (setpoint).
Uses feedback. Example: Thermostat controlling a heater, cruise control in a car.

• Components:

– Sensors: Input devices measuring physical quantities (e.g., temperature, pressure,


light, sound, motion, pH, magnetic field).
– Microprocessor/Computer: Processes sensor data, makes decisions based on pro-
gramming.
– ADC/DAC: Convert between analogue sensor signals and digital computer data,
and between digital commands and analogue actuator signals.
– Actuators: Output devices that affect the environment (e.g., heaters, motors, valves,
lights, pumps).

• Feedback: The output of the system influences future input (e.g., heater output changes
temperature sensor reading). Essential for control systems to maintain stability or reach a
target.

3.2 Logic Gates and Logic Circuits (3.2)


3.2.1 Logic Gates
Basic building blocks of digital circuits. Perform logical operations on one or more binary inputs
to produce a single binary output.

A X
• NOT Gate (Inverter) Function: Output X is 1 if input A is 0;
A X
Output X is 0 if input A is 1. (X = A) Truth Table: 0 1
1 0

19
A
X
• AND Gate B Function: Output X is 1 only if input A AND input
A B X
0 0 0
B are both 1. (X = A · B) Truth Table: 0 1 0
1 0 0
1 1 1

A
X
• OR Gate B Function: Output X is 1 if input A OR input B (or
A B X
0 0 0
both) are 1. (X = A + B) Truth Table: 0 1 1
1 0 1
1 1 1

A
X
• NAND Gate (NOT AND) B Function: Output X is 0 only if input
A B X
0 0 1
A AND input B are both 1. (Opposite of AND). (X = A · B) Truth Table: 0 1 1
1 0 1
1 1 0

A
X
• NOR Gate (NOT OR) B Function: Output X is 1 only if input A
A B X
0 0 1
AND input B are both 0. (Opposite of OR). (X = A + B) Truth Table: 0 1 0
1 0 0
1 1 0

A
X
• XOR Gate (Exclusive OR) B Function: Output X is 1 if input A
OR input B is 1, but NOT both. (Inputs are different). (X = A ⊕ B = AB + AB) Truth
A B X
0 0 0
Table: 0 1 1
1 0 1
1 1 0

Note: All gates except NOT have two inputs in this syllabus context.

3.2.2 Logic Circuits and Truth Tables


Combinations of logic gates form logic circuits designed to perform specific functions.

• Constructing Logic Circuits: Can be built based on:

– A problem statement (describing the desired logic).

20
– A logic expression (Boolean algebra).
– A truth table.

• Constructing Truth Tables: Used to determine the output of a logic circuit for all
possible input combinations. Can be derived from:

– A problem statement.
– A logic circuit (by tracing inputs through intermediate points).
– A logic expression.

Number of rows = 2n , where n is the number of inputs. Columns for inputs, intermediate
points, and final output(s).

• Constructing Logic Expressions: Representing the circuit’s function using Boolean


algebra. Can be derived from:

– A problem statement.
– A logic circuit.
– A truth table.

Example: Constructing Truth Table from Circuit Consider the circuit: A AND B =
P; B NOR C = Q; P OR Q = R; NOT R = X.

Inputs Intermediate Output


A B C P = A.B Q = B + C R = P+Q X=R
0 0 0 0 1 1 0
0 0 1 0 0 0 1
0 1 0 0 0 0 1
0 1 1 0 0 0 1
1 0 0 0 1 1 0
1 0 1 0 0 0 1
1 1 0 1 0 1 0
1 1 1 1 0 1 0

21
4 Processor Fundamentals
4.1 Central Processing Unit (CPU) Architecture (4.1)
4.1.1 Von Neumann Architecture
• Developed by John Von Neumann in the 1940s.

• Key concept: Stored Program Concept - Both program instructions and data are stored
together in the same main memory.

• Basic components:

– CPU (Central Processing Unit): Fetches, decodes, and executes instructions.


Contains ALU, CU, Registers.
– Main Memory (IAS - Immediate Access Store): Holds currently running pro-
grams and data.
– Buses: Connect components (Address Bus, Data Bus, Control Bus).
– Input/Output Devices.

• Instructions are executed sequentially unless altered by a control instruction (e.g., jump).

• Bottleneck: Shared bus for data and instructions can limit throughput (Von Neumann
bottleneck).

4.1.2 CPU Components


• Arithmetic Logic Unit (ALU): Performs arithmetic (+, -, *, /) and logical (AND, OR,
NOT, XOR) operations. May handle fixed-point and floating-point operations, sometimes
with separate units.

• Control Unit (CU): Manages the execution of instructions. Fetches instructions from
memory, decodes them, and sends control signals to other components (ALU, memory,
I/O) via the control bus to coordinate activities. Synchronises operations using the system
clock.

• Registers: Small, fast memory locations within the CPU used for temporary storage of
data or control information during processing.

– Program Counter (PC): Holds the memory address of the *next* instruction to
be fetched. Incremented after each fetch.
– Memory Address Register (MAR): Holds the memory address of the location
currently being accessed (read from or written to). Receives address from PC (for
fetch) or from instruction (for data access).
– Memory Data Register (MDR) / Memory Buffer Register (MBR): Tem-
porarily holds data being transferred between the CPU and main memory. Data read
from memory goes here; data to be written to memory is placed here.
– Current Instruction Register (CIR): Holds the instruction that has just been
fetched from memory and is currently being decoded and executed.
– Accumulator (ACC): A general-purpose register used to hold data being processed
by the ALU and store the results of calculations. (Syllabus assumes one main general-
purpose register, the ACC).
– Index Register (IX): Used in indexed addressing mode (assembly language) to
modify memory addresses. Holds an offset value.

22
– Status Register (SR) / Flags Register: Holds status flags (individual bits) indi-
cating results of operations or CPU state. Common flags:
∗ N (Negative): Set if result is negative.
∗ Z (Zero): Set if result is zero.
∗ C (Carry): Set if an operation produced a carry-out.
∗ V (Overflow): Set if an arithmetic operation resulted in overflow.

• System Clock: Generates timing signals (pulses) at a regular frequency (measured in Hz,
e.g., GHz). Synchronises all CPU operations and data transfers via the control bus. Faster
clock speed generally means faster processing (but other factors matter).

• Immediate Access Store (IAS): Another term for main memory (RAM) directly ac-
cessible by the CPU.

4.1.3 System Buses


Parallel pathways connecting CPU components and main memory. Width (number of parallel
wires/lines) affects performance.

• Address Bus: Carries memory addresses from the CPU (MAR) to main memory and I/O
devices. Unidirectional (CPU sends addresses out). Width determines the maximum
addressable memory (2width locations).

• Data Bus: Carries data between the CPU (MDR), main memory, and I/O devices. Bidi-
rectional. Width determines how much data can be transferred simultaneously (word
size).

• Control Bus: Carries control signals and timing signals from the CU to other compo-
nents, and status signals back to the CPU. Bidirectional. Includes signals like memory
read/write, clock pulses, interrupts, bus requests.

4.1.4 Factors Affecting Performance


• Clock Speed: Higher frequency means more fetch-execute cycles per second. Overclocking
(running faster than specified) can cause instability and overheating.

• Number of Cores: Multi-core CPUs (dual, quad, etc.) can execute multiple instruction-
s/processes simultaneously (parallel processing), improving performance for suitable tasks.
Communication overhead between cores limits linear scaling.

• Bus Width: Wider address bus allows access to more memory. Wider data bus allows
more data transfer per cycle (larger word size).

• Cache Memory: Small, fast SRAM between CPU and main memory. Stores frequently
accessed data/instructions. Reduces average memory access time. Larger cache / multiple
levels (L1, L2, L3) generally improve performance.

4.1.5 Computer Ports


Interfaces for connecting peripheral devices.

• USB (Universal Serial Bus): Asynchronous serial interface. Standard for connecting
diverse peripherals (keyboards, mice, printers, drives, cameras). Hot-pluggable, provides
power. Different versions (2.0, 3.x, USB-C) offer varying speeds. Computer auto-detects
devices and loads drivers.

23
• HDMI (High-Definition Multimedia Interface): Digital interface for transmitting
uncompressed video and compressed/uncompressed audio data (e.g., computer to moni-
tor/TV). Supports HDCP (High-bandwidth Digital Content Protection) for anti-piracy.

• VGA (Video Graphics Array): Older analogue interface for video output (computer
to monitor). Lower resolution and quality compared to digital interfaces like HDMI. Being
phased out.

4.1.6 Fetch-Execute Cycle


The fundamental process by which the CPU executes instructions.

1. Fetch:

• Address of next instruction is copied from PC to MAR.


• Instruction at address in MAR is copied from memory to MDR (via data bus). Control
bus signals memory read.
• Instruction is copied from MDR to CIR.
• PC is incremented to point to the next instruction.

2. Decode:

• CU decodes the instruction in the CIR.


• Interprets opcode and operand(s).

3. Execute:

• CU sends control signals to relevant components (ALU, registers, memory).


• Operation is performed (e.g., data transfer, calculation, logic operation, jump).
• Status register flags may be updated.

4. Check for Interrupts: Before starting the next cycle, the CPU checks for pending inter-
rupts. If an interrupt exists and has high enough priority, the interrupt handling routine
is initiated.

Register Transfer Notation (RTN) Example:

• ‘MAR <- [PC]‘ (Content of PC copied to MAR)

• ‘PC <- [PC] + 1‘ (PC incremented)

• ‘MDR <- [[MAR]]‘ (Data at address stored in MAR copied to MDR)

• ‘CIR <- [MDR]‘ (Content of MDR copied to CIR)

4.1.7 Interrupts
Signals to the CPU from hardware or software indicating an event needing immediate attention.
Allows efficient handling of I/O and errors without constant polling.

• Purpose: Handle I/O device requests (e.g., keyboard input ready, printer finished), hard-
ware errors (e.g., memory parity error), software errors (e.g., division by zero), user inter-
actions (e.g., Ctrl+Break), timer signals (for multitasking).

• Handling Process:

24
1. CPU checks for interrupts (usually at end of fetch-execute cycle).
2. If an interrupt is pending and enabled/high priority:
– Current process state (PC, registers) is saved (usually onto the system stack).
– PC is loaded with the start address of the appropriate Interrupt Service Rou-
tine (ISR) or interrupt handler.
– ISR is executed to handle the interrupt cause.
– Saved process state is restored from the stack.
– Interrupted process resumes execution.

• Interrupt Priority: Interrupts have priorities to manage conflicts (e.g., power failure
interrupt > keyboard interrupt). Higher priority interrupts can interrupt lower priority
ISRs.

4.2 Assembly Language (4.2)


4.2.1 Relationship to Machine Code
• Machine Code: The lowest-level language understood directly by the CPU. Consists of
binary opcodes and operands. Machine-specific.

• Assembly Language: A low-level language using human-readable mnemonics for instruc-


tions (opcodes) and symbolic names for addresses/data (operands, labels). Closely maps
to machine code (often one-to-one). Machine-specific.

• Assembler: A translator program that converts assembly language source code into ma-
chine code (object code).

4.2.2 Two-Pass Assembler


Needed to handle forward references (using a label before it’s defined).

• Pass 1:

– Reads source code line by line.


– Ignores comments.
– Allocates memory addresses.
– Builds a Symbol Table containing labels and their corresponding memory addresses.
– Performs some basic syntax checks (e.g., valid opcodes).

• Pass 2:

– Reads source code again.


– Generates machine code (object code) for each instruction.
– Uses the symbol table created in Pass 1 to resolve label addresses (replace symbolic
addresses with actual memory addresses in operands).
– Performs further syntax checks.
– Outputs the machine code program.

25
4.2.3 Instruction Set (Example - based on syllabus)
Assumes one general-purpose register (Accumulator - ACC) and an Index Register (IX). Note:
‘<address>‘ can be absolute or symbolic. ‘#n‘ = denary, ‘Bn‘ = binary, ‘&n‘ = hexadecimal.

Table 1: Example Assembly Instruction Set

Opcode Operand Explanation


LDM #n Load ACC with immediate denary value n
LDD <address> Load ACC with contents of memory address (Direct)
LDI <address> Load ACC with contents of address pointed to by contents of <address> (Indirec
LDX <address> Load ACC with contents of address (<address> + [IX]) (Indexed)
LDR #n Load IX with immediate denary value n
MOV <register> Move ACC contents to specified register (IX)
STO <address> Store ACC contents to memory address
IN Key in character, store ASCII value in ACC
OUT Output character whose ASCII value is in ACC
ADD <address> Add contents of address to ACC
ADD #n/Bn/&n Add immediate value n to ACC
SUB <address> Subtract contents of address from ACC
SUB #n/Bn/&n Subtract immediate value n from ACC
INC <register> Increment register (ACC or IX) by 1
DEC <register> Decrement register (ACC or IX) by 1
CMP <address> Compare ACC with contents of address
CMP #n Compare ACC with immediate value n
CMI <address> Compare ACC with contents of address pointed to by contents of <address> (In
JMP <address> Unconditional jump to address
JPE <address> Jump to address if previous compare was Equal/True (Zero flag set)
JPN <address> Jump to address if previous compare was Not Equal/False (Zero flag clear)
END Return control to operating system
<label>: <instruction> Assigns symbolic address <label> to the instruction
<label>: <data> Assigns symbolic address <label> to memory location containing <data>

4.2.4 Addressing Modes


How the operand of an instruction refers to the data being operated on.

• Immediate Addressing: The operand *is* the actual value to be used. Fast, but value
is fixed in the instruction. (e.g., ‘LDM #123‘ - load 123 into ACC).

• Direct Addressing (Absolute Addressing): The operand is the memory address where
the value is stored. (e.g., ‘LDD 200‘ - load value from address 200 into ACC).

• Indirect Addressing: The operand is an address that contains *another* address, where
the actual value is stored. Requires two memory accesses. (e.g., ‘LDI 200‘ - if address 200
contains 300, load value from address 300 into ACC).

• Indexed Addressing: The operand address is added to the contents of the Index Register
(IX) to form the effective address where the value is stored. Useful for accessing arrays.
(e.g., ‘LDX 200‘ - if IX contains 4, load value from address 204 into ACC).

26
• Relative Addressing: The operand is an offset added to the current Program Counter
(PC) value to determine the target address. Used for jumps/branches within a relocatable
code block. (e.g., ‘JMP +5‘ - jump 5 locations forward from the current instruction).

• Symbolic Addressing: Using labels instead of numerical addresses in assembly source


code. The assembler resolves these to actual addresses during assembly. (e.g., ‘LDD
MyVariable‘).

4.3 Bit manipulation (4.3)


4.3.1 Binary Shifts
Operations that move the bits in a register left or right.

• Logical Shift:

– Bits shifted out are lost.


– Vacated positions are filled with zeros.
– LSL (Logical Shift Left): Multiplies by powers of 2 (for unsigned numbers).
– LSR (Logical Shift Right): Divides by powers of 2 (for unsigned numbers).

• Arithmetic Shift:

– Preserves the sign bit (MSB).


– ASL (Arithmetic Shift Left): Multiplies by powers of 2. Same as LSL. Overflow
can occur if sign bit changes unexpectedly.
– ASR (Arithmetic Shift Right): Divides by powers of 2 (for signed two’s comple-
ment numbers). Vacated MSB position is filled by copying the original sign bit. Bits
shifted out from the right are lost.

• Cyclic Shift (Rotate):

– Bits shifted out from one end are inserted into the vacated positions at the other end.
No bits are lost.
– CSL / ROL (Cyclic Shift Left / Rotate Left): MSB wraps around to LSB
position.
– CSR / ROR (Cyclic Shift Right / Rotate Right): LSB wraps around to MSB
position.
– Sometimes includes the Carry flag in the rotation (Rotate through Carry).

Assembly Instructions (Logical):

• ‘LSL #n‘: Logical shift left ACC by n places.

• ‘LSR #n‘: Logical shift right ACC by n places.

4.3.2 Using Bit Manipulation for Monitoring/Control


Individual bits within a register or memory location can represent status flags or control signals
(e.g., for sensors/actuators). Bitwise logical operations (AND, OR, XOR) are used with masks
to check, set, or clear specific bits.

• Mask: A binary value used in a bitwise operation to target specific bits.

27
• Checking a bit (Test): Use AND with a mask that has a ’1’ only in the bit position(s)
to check, and ’0’s elsewhere. If the result is non-zero, the bit was set (1). If the result is
zero, the bit was clear (0). Example: Check if bit 3 (value 8 = 00001000) is set in ACC.
‘AND #B00001000‘. If result is ‘00001000‘, bit 3 was set. If result is ‘00000000‘, bit 3 was
clear.

• Setting a bit: Use OR with a mask that has a ’1’ in the bit position(s) to set, and ’0’s
elsewhere. This forces the target bit(s) to 1 without affecting others. Example: Set bit 4
(value 16 = 00010000) in ACC. ‘OR #B00010000‘.

• Clearing a bit (Unset): Use AND with a mask that has a ’0’ in the bit position(s) to
clear, and ’1’s elsewhere. This forces the target bit(s) to 0 without affecting others. Exam-
ple: Clear bit 1 (value 2 = 00000010) in ACC. Mask is ‘11111101‘. ‘AND #B11111101‘.

• Toggling a bit: Use XOR with a mask that has a ’1’ in the bit position(s) to toggle, and
’0’s elsewhere. This flips the state of the target bit(s) without affecting others. Example:
Toggle bit 0 (value 1 = 00000001) in ACC. ‘XOR #B00000001‘.

Assembly Instructions (Bitwise):

• ‘AND #n/Bn/&n‘ or ‘AND <address>‘: Bitwise AND ACC with operand/memory con-
tent.

• ‘XOR #n/Bn/&n‘ or ‘XOR <address>‘: Bitwise XOR ACC with operand/memory con-
tent.

• ‘OR #n/Bn/&n‘ or ‘OR <address>‘: Bitwise OR ACC with operand/memory content.

28
5 System Software
5.1 Operating Systems (5.1)
5.1.1 Need for an Operating System (OS)
• Provides an environment for application software to run.

• Manages computer hardware resources (CPU, memory, storage, peripherals).

• Provides a user interface (GUI or CLI) for interaction.

• Hides the complexity of the hardware from users and applications.

• Provides security and file management.

5.1.2 Key Management Tasks


• Memory Management: Allocating and deallocating main memory space to processes.
Includes organisation (e.g., paging, segmentation), optimisation (tracking free/used mem-
ory, swapping), and protection (preventing processes from interfering with each other’s
memory).

• File Management: Creating, deleting, organising, and controlling access to files and
directories. Manages storage space on secondary devices. Defines file naming conventions
and logical storage formats (e.g., FAT, NTFS).

• Security Management: Protecting the system and user data from unauthorised access,
modification, or destruction. Includes user authentication (logins, passwords), access con-
trol (permissions, privileges), firewall communication, and often integrates with antivirus
software.

• Hardware Management (Input/Output Management): Managing communication


with peripheral devices (printers, disks, keyboard, monitor). Uses device drivers to trans-
late OS commands into device-specific instructions. Manages queues and buffers for I/O
operations. Handles interrupts from devices.

• Process Management: Managing the execution of programs (processes). Includes schedul-


ing (deciding which process runs next), allocating CPU time, handling inter-process com-
munication, and managing process states (running, ready, blocked). (Covered more in A
Level).

5.1.3 Utility Software


System software designed to help analyse, configure, optimise or maintain a computer. Often
bundled with the OS, but can be separate.

• Disk Formatter: Prepares a storage disk (HDD, SSD, flash drive) for use by creating a
file system structure (e.g., partitions, directories, FAT/NTFS). Erases existing data. May
perform surface checks for bad sectors.

• Virus Checker (Antivirus Software): Detects, prevents, and removes malicious soft-
ware (malware), including viruses, worms, Trojans, spyware. Uses signature databases and
heuristic analysis. Often includes quarantine features. Needs regular updates.

29
• Defragmentation Software: Reorganises files stored on a magnetic hard disk drive
(HDD) so that fragments of files are stored in contiguous blocks/sectors. Reduces head
movement and improves file access speed. Not generally needed (and can reduce lifespan)
for SSDs.

• Disk Content Analysis / Disk Repair Software:

– Analysis: Scans drives to show disk space usage by files/folders, helps identify large
or unnecessary files to free up space.
– Repair: Checks disk for file system errors, bad sectors. Attempts to recover data
from bad sectors or mark them as unusable. (e.g., CHKDSK, Disk Utility).

• File Compression: Reduces the size of files for storage or transmission (e.g., ZIP, RAR).
Uses lossless or lossy algorithms.

• Backup Software: Creates copies of data files (and sometimes system files) onto separate
storage media (external drive, cloud storage) for recovery in case of data loss (hardware
failure, accidental deletion, malware). Can often be scheduled.

5.1.4 Program Libraries


Collections of pre-written, pre-compiled code (functions, procedures, classes) that can be reused
by programmers.

• Purpose: Saves development time, promotes code reuse, provides standardised and tested
routines for common tasks (e.g., I/O, math functions, string manipulation).

• Static Linking: Library code is copied directly into the executable file during compilation.
Creates larger executables but they are self-contained.

• Dynamic Linking (Dynamic Link Libraries - DLLs / Shared Objects): Library


code remains in separate files. The main program contains links/references to the library
routines. The OS loads the required library routines into memory at run-time when needed.

– Benefits: Smaller executables, saves memory (library loaded once and shared by
multiple programs), libraries can be updated independently of the main program.
– Drawbacks: Requires the correct library versions to be present at run-time ("DLL
hell"), potential for malicious modification of shared libraries.

5.2 Language Translators (5.2)


Software that converts source code written in one programming language into another (usually
machine code or an intermediate code).

5.2.1 Types of Translators


• Assembler: Translates assembly language (low-level, mnemonic-based) into machine code
(binary). Specific to a particular CPU architecture. (See Section 4.2).

• Compiler: Translates entire high-level language source code into machine code (or some-
times intermediate code like bytecode) in one go. Creates a standalone executable file.
Reports all syntax errors after the full compilation attempt. The resulting executable runs
faster than interpreted code.

30
• Interpreter: Translates and executes high-level language source code one statement or
line at a time. Does not create a separate executable file. Stops execution immediately
when the first error is found. Easier for debugging during development. Slower execution
speed as translation happens every time the program runs.

5.2.2 Compiler vs. Interpreter

Compiler Interpreter
Translates entire source code before execu- Translates and executes code line by line.
tion.
Produces an executable object code file. No separate object code file produced.
Execution is generally faster after compila- Execution is generally slower (translation
tion. overhead).
Finds all syntax errors at once after compi- Stops at the first syntax error encountered.
lation attempt.
Debugging logic errors can be harder (need Debugging can be easier (errors identified Jus-
to recompile). immediately, can inspect variables line by
line).
End-user does not need the compiler to run End-user needs the interpreter to run the
the program. program.
Source code is kept private from the end- Source code is usually distributed and visi-
user. ble to the end-user.
Optimisation of code possible during com- Less opportunity for optimisation.
pilation.
tification: Interpreters are often preferred during development for ease of debugging. Compilers
are preferred for distributing finished applications due to speed and protection of source code.

5.2.3 Partial Compilation/Interpretation (Bytecode)


• Some languages (e.g., Java, Python) use a hybrid approach.

• Source code is first compiled into an intermediate, low-level code called bytecode.

• Bytecode is platform-independent.

• This bytecode is then executed by an interpreter (often called a Virtual Machine, e.g.,
Java Virtual Machine - JVM).

• Offers portability (compile once, run anywhere there’s a VM) and some performance benefit
over pure interpretation, but slower than fully compiled native machine code.

5.2.4 Integrated Development Environment (IDE)


A software suite consolidating basic tools required for software development into a single interface.
• Features:

– Source Code Editor: Text editor designed for coding, often with:
∗ Syntax Highlighting: Colour-codes keywords, variables, comments for readability.
∗ Context-Sensitive Prompts / Autocompletion: Suggests variable names, function
names, keywords as you type.
∗ Automatic Indentation / Prettyprint: Formats code layout for readability.
∗ Expand/Collapse Code Blocks: Hides/shows sections of code (e.g., functions,
loops) for easier navigation.

31
– Initial Error Detection:
∗ Dynamic Syntax Checking: Flags syntax errors as you type, before compila-
tion/interpretation.
– Build Automation Tools: Includes compiler and/or interpreter.
– Debugger: Tools to help find and fix logic/run-time errors:
∗ Single Stepping: Execute code one line/instruction at a time.
∗ Breakpoints: Pause execution at specific lines.
∗ Watch Windows / Variable Inspection: View the values of variables and expres-
sions at breakpoints or during stepping.
∗ Report Window: Displays output, error messages, debug information.

32
6 Security, Privacy and Data Integrity
6.1 Data Security (6.1)
6.1.1 Security, Privacy, Integrity Definitions
• Data Security: Protecting data from unauthorised access, use, disclosure, alteration, or
destruction. Includes measures for prevention and recovery.

• Data Privacy: Protecting personal information from unauthorised access or sharing.


Relates to an individual’s right to control their personal data. Often governed by data
protection laws.

• Data Integrity: Maintaining the accuracy, consistency, and trustworthiness of data


throughout its lifecycle. Ensuring data is not corrupted or accidentally/maliciously al-
tered.

Note: Security is about protecting the data container/system, privacy is about controlling access
to personal data, integrity is about ensuring the data itself is correct.

6.1.2 Need for Security


Both the computer system itself and the data it holds need protection from threats like hardware
failure, malware, hacking, and accidental damage/deletion.

6.1.3 Security Measures (System and Data)


• User Accounts & Passwords: Authenticate users, restricting access based on identity.
Passwords should be strong (mix of cases, numbers, symbols) and changed regularly.

• Authentication Techniques: Methods to verify identity beyond simple passwords:

– Biometrics: Using unique biological traits (fingerprint, face recognition, iris/retina


scan, voice recognition).
– Digital Signatures: Using cryptography (public/private keys) to verify the sender
of a digital message and ensure message integrity.
– Multi-Factor Authentication (MFA): Requiring two or more verification methods
(e.g., password + code from phone app).

• Firewall: Hardware or software barrier between a trusted internal network and untrusted
external networks (like the internet). Monitors and filters incoming/outgoing traffic based
on security rules, blocking unauthorised access.

• Anti-Virus Software: Detects and removes known malware (viruses, worms, Trojans).
Uses signature databases and heuristics. Needs regular updates.

• Anti-Spyware Software: Detects and removes software that secretly gathers user infor-
mation (keystrokes, browsing habits).

• Encryption: Scrambling data using an algorithm and a key, making it unreadable without
the correct decryption key. Protects data confidentiality if intercepted or stolen.

• Access Rights / Privileges: Assigning permissions to users/groups, controlling what


actions they can perform (read, write, execute, delete) on specific files, folders, or system
resources. Enforces the principle of least privilege.

33
6.1.4 Threats (Network/Internet)
• Malware (Malicious Software):

– Virus: Code that replicates by attaching to other programs. Requires user action
(e.g., running infected program) to spread. Can corrupt/delete data.
– Worm: Standalone malware that replicates itself to spread across networks, exploiting
vulnerabilities. Does not need to attach to a program. Can consume bandwidth,
install backdoors.
– Trojan Horse: Malware disguised as legitimate software. Doesn’t self-replicate but
performs malicious actions when run (e.g., stealing data, installing backdoor).
– Spyware: Secretly monitors user activity (keystrokes, websites visited) and sends
information to third parties.
– Ransomware: Encrypts user’s data and demands payment for the decryption key.

• Hackers: Individuals attempting to gain unauthorised access to computer systems or data.


Motives vary (theft, espionage, disruption, challenge). Ethical hackers test security with
permission.

• Phishing: Deceptive emails or messages attempting to trick users into revealing sensitive
information (passwords, credit card numbers) by impersonating legitimate entities (banks,
services). Often directs users to fake websites.

• Pharming: Redirecting users from legitimate websites to fraudulent ones without their
knowledge. Can be done by modifying host files on a user’s computer or via DNS cache
poisoning (compromising a DNS server to return incorrect IP addresses). More difficult to
detect than phishing.

6.1.5 Restricting Risks


Combining security measures provides layered defence. Key methods include strong authenti-
cation, firewalls, up-to-date security software, user education (recognising phishing/malware),
encryption for sensitive data, and regular backups. Access rights limit the potential damage if
an account is compromised.

6.2 Data Integrity (6.2)


Ensuring data accuracy and consistency. Primarily achieved through validation and verification.

6.2.1 Data Validation


Automatic computer check to ensure data entered is sensible and reasonable. Cannot guarantee
correctness. Performed *during* data entry.

• Range Check: Checks if numerical data is within a specified lower and upper limit (e.g.,
age between 0 and 120).

• Format Check: Checks if data matches a specific pattern (e.g., date as DD/MM/YYYY,
postcode as LLN NLL).

• Length Check: Checks if data has the correct number of characters (e.g., phone number
has 11 digits). Can be fixed length or within a range.

• Presence Check: Checks that a required field has actually been filled in (not left blank).

34
• Existence Check (Lookup Check): Checks if entered data exists in a predefined list or
database table (e.g., checking if a customer ID exists).
• Limit Check: Similar to range check, but only checks against one limit (upper OR lower)
(e.g., quantity ordered must be > 0).
• Check Digit: An extra digit calculated from the other digits in a number (e.g., ISBN,
barcode number). Recalculated upon entry; if calculation doesn’t match the entered check
digit, an error occurred. Catches most single-digit errors and transpositions. (Example
algorithm: Modulo-11).

6.2.2 Data Verification


Checking that data entered matches the original source data. Aims to prevent transcription
errors.
• During Data Entry:
– Double Entry: Data is entered twice (often by different operators). The computer
compares the two entries; discrepancies indicate an error. Very effective but time-
consuming.
– Visual Check (Proofreading): User manually compares the entered data on the
screen with the original source document. Prone to human error.
• During Data Transfer: Checking data hasn’t been corrupted during transmission be-
tween devices/systems.
– Parity Check:
∗ An extra bit (parity bit) is added to each byte/character being transmitted.
∗ Even Parity: The parity bit is set to 0 or 1 to make the total number of ’1’ bits
in the byte (including the parity bit) even.
∗ Odd Parity: The parity bit is set to make the total number of ’1’ bits odd.
∗ Sender and receiver agree on the parity type. Receiver checks if the received byte
has the correct parity. If not, an error is detected.
∗ Detects single-bit errors but fails if an even number of bits are flipped.
∗ Parity Block: Extends parity checking to a block of data, calculating both hor-
izontal (per byte) and vertical (per bit position) parity, often stored in a final
parity byte. Allows detection and correction of single-bit errors by identifying the
row and column of the error.
– Checksum:
∗ A numerical value calculated from a block of data using an algorithm (e.g., sum
of byte values modulo 256).
∗ The checksum is transmitted along with the data block.
∗ Receiver recalculates the checksum from the received data and compares it with
the transmitted checksum. If they differ, an error occurred.
∗ More robust than simple parity check at detecting multiple errors.
– Automatic Repeat Request (ARQ):
∗ Error-control protocol using acknowledgements and timeouts.
∗ Receiver sends a positive acknowledgement (ACK) if data received correctly (e.g.,
checksum matches), or a negative acknowledgement (NAK) or no acknowledge-
ment if an error is detected.
∗ Sender retransmits data if it receives a NAK or if a timeout occurs (no ACK
received within a set time).

35
7 Ethics and Ownership
7.1 Ethics and Ownership (7.1)
7.1.1 Ethics in Computing
• Ethics: Moral principles governing behaviour, especially in a professional context. A code
of conduct.
• Need for Ethics: Computing professionals’ work impacts society significantly. Ethical
codes guide responsible behaviour, protect the public, maintain professional integrity, and
address issues like privacy, accuracy, property rights, and access.
• Professional Bodies: Organisations like BCS (British Computer Society) and IEEE
(Institute of Electrical and Electronics Engineers) establish codes of conduct/ethics for
their members, promoting professionalism and accountability. Adherence demonstrates
commitment to ethical practice. Key principles often include: public interest, competence,
integrity, duty to profession/employer/client.
• Ethical vs. Unethical Action: Acting ethically means adhering to moral principles
and professional codes. Unethical actions violate these principles (e.g., misusing data,
plagiarism, creating insecure software, unfair treatment). The impact can range from loss
of trust to significant harm.
• Legal vs. Ethical: An action can be legal but unethical (e.g., exploiting a loophole that
harms users), or illegal but potentially viewed by some as ethical in extreme circumstances
(rare). Ethics often goes beyond legal requirements.

7.1.2 Copyright
• Copyright Legislation: Laws granting creators of original works (software, literature,
music, art) exclusive rights to control their reproduction, distribution, adaptation, and
display for a certain period.
• Need: Protects creators’ intellectual property, encourages creativity by allowing creators
to benefit financially and control their work, prevents unauthorised copying and plagiarism.
• Software Piracy: Unauthorised copying, distribution, or use of copyrighted software.
Illegal and unethical. Measures to prevent it include product keys, licence agreements,
dongles, DRM.

7.1.3 Software Licensing


Defines the permissions and restrictions governing the use and distribution of software.
• Commercial Software: Sold for profit. Typically licensed for use on a limited number
of devices. Usually proprietary (source code not available). Fully copyright protected.
• Shareware: Distributed freely for a trial period. Payment required for continued use,
often unlocking full features or removing limitations. Copyright protected.
• Freeware: Distributed free of charge, but copyright restrictions still apply (cannot mod-
ify, often cannot redistribute). Source code not usually available. (e.g., Adobe Acrobat
Reader).
• Free Software (FSF Definition): Focuses on user freedom. Grants users the right
to run, copy, distribute, study, change, and improve the software. Source code must be
available. Emphasises user rights. Governed by specific licences like GPL.

36
• Open Source Software (OSI Definition): Similar freedoms to Free Software, but
philosophy focuses more on the practical benefits of open development (collaboration, peer
review). Source code must be available. Governed by OSI-approved licences.

Justification: Choice depends on developer’s goals (profit, community building, user freedom)
and user needs (cost, ability to modify, support).

7.1.4 Artificial Intelligence (AI)


Machines or applications performing tasks that typically require human intelligence (e.g., learn-
ing, problem-solving, decision-making, language understanding).

• Applications: Autonomous vehicles, medical diagnosis, financial modelling, language


translation, game playing, robotics, recommendation systems, scientific research.

• Impacts:

– Social: Potential job displacement due to automation, changes in human interaction,


ethical dilemmas (bias in algorithms, autonomous decisions), potential for enhanced
accessibility, new forms of entertainment/creativity.
– Economic: Increased productivity, creation of new industries/jobs (AI development,
data science), disruption of existing industries, potential increase in inequality if ben-
efits aren’t shared widely.
– Environmental: AI can help model climate change, optimise resource usage (energy
grids, water supply), monitor pollution, and aid conservation efforts. However, AI
computation itself requires significant energy.

• Ethical Considerations: Bias in training data leading to unfair outcomes, accountability


for AI decisions (especially autonomous systems), privacy concerns with data collection,
potential misuse (autonomous weapons, surveillance), the "black box" problem (difficulty
understanding how some AI makes decisions).

37
8 Databases
8.1 Database Concepts (8.1)
8.1.1 File-Based Approach Limitations
Storing data in separate files for different applications leads to:

• Data Redundancy: The same data stored in multiple files (e.g., customer name and
address in both sales and billing files). Wastes storage space.

• Data Inconsistency: If data is updated in one file but not others where it’s duplicated,
inconsistencies arise (e.g., different addresses for the same customer). Compromises data
integrity.

• Data Dependence: Applications are dependent on the specific file structure. Changes
to the file structure require changes to the application programs that use it.

• Limited Data Sharing: Difficult for different applications to access and share data stored
in different file formats.

• Poor Security/Access Control: Difficult to enforce consistent security rules across


multiple separate files.

8.1.2 Relational Database Features


Relational databases overcome file-based limitations:

• Reduced Redundancy: Data is stored logically in tables, with relationships linking


them. Ideally, each piece of data is stored only once (except for foreign keys).

• Improved Consistency: Reducing redundancy means updates only need to happen in


one place, ensuring consistency across applications using the data. Referential integrity
helps maintain consistency between related tables.

• Data Independence: The database structure (how data is stored - physical schema)
can be changed without necessarily affecting application programs, which interact with a
logical view (logical schema). Managed by the DBMS.

• Improved Data Sharing & Access: Centralised data store accessible by multiple au-
thorised applications and users. Query languages (like SQL) provide flexible data retrieval.

• Enhanced Security: DBMS provides features for user authentication, access control
(privileges), and backups.

8.1.3 Relational Database Terminology


• Entity: A real-world object or concept about which data is stored (e.g., Student, Course,
Teacher).

• Table: Represents an entity; stores data in rows and columns.

• Attribute: A property or characteristic of an entity; represented as a column (field) in a


table (e.g., StudentName, CourseID).

• Tuple (Record): A single instance of an entity; represented as a row in a table (e.g., data
for one specific student).

38
• Primary Key (PK): An attribute (or set of attributes) that uniquely identifies each
tuple/row in a table. Cannot be NULL.

• Candidate Key: An attribute (or set of attributes) that *could* serve as the primary
key (i.e., it’s unique for every tuple).

• Secondary Key: A candidate key that was not chosen as the primary key. Often used
for indexing to speed up searches on non-PK attributes.

• Foreign Key (FK): An attribute (or set of attributes) in one table that refers to the
primary key of another table. Used to establish and enforce relationships between tables.

• Relationship: An association between two or more tables, usually established via foreign
keys. Types:

– One-to-One (1:1): Each record in Table A relates to exactly one record in Table B,
and vice versa.
– One-to-Many (1:M): One record in Table A can relate to many records in Table B,
but each record in Table B relates to only one record in Table A. (FK is in the ’Many’
side table).
– Many-to-Many (M:M): One record in Table A can relate to many records in Table B,
and vice versa. Implemented using a linking/junction table containing foreign keys
from both tables.

• Referential Integrity: A rule ensuring that relationships between tables remain consis-
tent. Means that a foreign key value must either match an existing primary key value in
the referenced table or be NULL. Prevents "orphan" records.

• Indexing: A data structure (often a B-tree) associated with a table column (or columns)
that speeds up data retrieval operations (like SELECT WHERE...). Works like an index
in a book. Can be created on primary keys (often automatic) or other columns (secondary
keys/attributes).

8.1.4 Entity-Relationship (E-R) Diagrams


Graphical representation of database structure.

• Shows entities (usually as rectangles).

• Shows attributes associated with entities.

• Shows relationships between entities (usually as lines with diamonds or using crow’s foot
notation).

• Indicates relationship cardinality (1:1, 1:M, M:M) using symbols on the relationship lines.

8.1.5 Normalisation
The process of organising data in a database efficiently to reduce redundancy and improve data
integrity by structuring tables and relationships. Aims to eliminate undesirable characteristics
like insertion, update, and deletion anomalies.

• First Normal Form (1NF):

– Each cell/attribute intersection contains only a single, atomic value (no repeating
groups or multi-value attributes).

39
– Each record is unique (requires a primary key).

• Second Normal Form (2NF):

– Must be in 1NF.
– All non-key attributes must be fully functionally dependent on the *entire* primary
key. (Applies mainly when the PK is composite - made of multiple attributes).
– No partial dependencies (where a non-key attribute depends on only part of the com-
posite primary key). Achieved by splitting tables.

• Third Normal Form (3NF):

– Must be in 2NF.
– No transitive dependencies (where a non-key attribute depends on another non-key
attribute, rather than directly on the primary key). Achieved by splitting tables
further.
– Mantra: Attributes depend on "the key, the whole key, and nothing but the key".

Producing Normalised Design: Involves starting with unnormalised data (e.g., a single large
table or description) and progressively applying the rules of 1NF, 2NF, and 3NF, splitting tables
and identifying primary/foreign keys as needed.

8.2 Database Management Systems (DBMS) (8.2)


Software that enables users to create, maintain, control, and access databases. Acts as an
interface between the database and users/applications.

8.2.1 DBMS Features


• Data Management: Handles storage, retrieval, and updating of data.

• Data Dictionary / Metadata Management: Stores information *about* the database


structure (table names, attribute names, data types, relationships, constraints, indexes).

• Data Modelling Support: Tools to help define the logical schema.

• Data Integrity Enforcement: Enforces constraints like primary keys, foreign keys (ref-
erential integrity), data types, validation rules.

• Data Security: Provides user authentication, access control (privileges/permissions),


views (restricting access to certain data), often encryption support.

• Backup and Recovery Procedures: Utilities to back up the database and restore it in
case of failure.

• Concurrency Control: Manages simultaneous access by multiple users, preventing con-


flicts (e.g., using locking mechanisms).

• Query Language Interface: Allows users to retrieve and manipulate data (e.g., SQL).

40
8.2.2 DBMS Software Tools
• Developer Interface: Provides tools for database administrators and developers to de-
fine the database structure (DDL), manipulate data (DML), manage users, and monitor
performance. Can be command-line or graphical.

• Query Processor: Component that interprets, optimises, and executes queries (usually
SQL) submitted by users or applications. Includes DDL interpreter, DML compiler, and
query evaluation engine.

8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
(8.3)
Subsets of SQL (Structured Query Language), the standard language for relational databases.

8.3.1 Roles of DDL and DML


• DDL (Data Definition Language): Used to define, modify, and remove the database
structure (schema). Commands deal with tables, attributes, keys, indexes, constraints.
Examples: ‘CREATE‘, ‘ALTER‘, ‘DROP‘.

• DML (Data Manipulation Language): Used to retrieve, insert, delete, and update
data *within* the tables. Commands deal with the actual data records/rows. Examples:
‘SELECT‘, ‘INSERT‘, ‘UPDATE‘, ‘DELETE‘.

8.3.2 SQL (DDL) Statements


• CREATE DATABASE database_name;

• CREATE TABLE table_name (


attribute1 DATATYPE [constraint],
attribute2 DATATYPE [constraint],
...
PRIMARY KEY (attribute_pk),
FOREIGN KEY (attribute_fk) REFERENCES referenced_table(referenced_pk_attribute)
);

• Common Data Types: CHARACTER(n), VARCHAR(n), BOOLEAN (often stored as 0/1 or


T/F), INTEGER, REAL (or FLOAT, DECIMAL), DATE, TIME.

• ALTER TABLE table_name ADD attribute_name DATATYPE;

• ALTER TABLE table_name ADD PRIMARY KEY (attribute_name);

• ALTER TABLE table_name ADD FOREIGN KEY (attribute_fk) REFERENCES referenced_table(referen

• DROP TABLE table_name;

• DROP DATABASE database_name;

8.3.3 SQL (DML) Statements


• Querying Data (‘SELECT‘):

– SELECT attribute1, attribute2 FROM table_name; (Select specific columns)


– SELECT * FROM table_name; (Select all columns)

41
– SELECT ... FROM table_name WHERE condition; (Filter rows, e.g., WHERE Age >
18, WHERE Name = ’Smith’)
– SELECT ... FROM table_name ORDER BY attribute [ASC|DESC]; (Sort results)
– SELECT COUNT(*), AVG(Salary), SUM(Sales) FROM Employees GROUP BY Department;
(Aggregate functions with grouping)
– SELECT T1.colA, T2.colB FROM Table1 T1 INNER JOIN Table2 T2 ON T1.key = T2.key;
(Combine rows from two tables based on a related key)
– Aggregate Functions: COUNT, SUM, AVG, MIN, MAX.

• Maintaining Data:

– INSERT INTO table_name (attribute1, attribute2) VALUES (value1, value2);


– UPDATE table_name SET attribute1 = new_value WHERE condition;
– DELETE FROM table_name WHERE condition;

Note: Understanding given SQL statements and writing simple DDL/DML statements (queries
up to 2 tables, basic maintenance) is required.

42
9 Algorithm Design and Problem-solving
Refer to Pseudocode Guide www. cambridgeinternational. org/ support for specific syntax.

9.1 Computational Thinking Skills (9.1)


9.1.1 Abstraction
• Definition: Identifying the essential features of a problem or system while ignoring irrel-
evant details. Simplifying complexity.

• Need/Benefits: Reduces complexity, makes problems easier to understand and model,


allows focus on core issues, leads to more manageable solutions, faster development.

• Purpose: To create a simplified representation (model) suitable for solving a specific


problem or understanding a particular aspect of a system.

• Producing Abstract Models: Involves identifying the purpose, gathering information,


selecting relevant details, and discarding unnecessary ones (e.g., a road map vs. a satellite
image).

9.1.2 Decomposition
• Definition: Breaking down a complex problem or system into smaller, more manageable
sub-problems or components.

• Use: Each sub-problem can be tackled independently, making the overall problem easier to
solve and understand. Leads naturally to modular program design (procedures/functions).

9.2 Algorithms (9.2)


9.2.1 Algorithm Fundamentals
• Definition: A sequence of well-defined, unambiguous steps to solve a problem or perform
a task.

• Identifiers: Use meaningful names for variables, constants, arrays, etc. Follow naming
conventions (start with letter, use letters/numbers). Keep track using an identifier table
(listing name and purpose/description).

• Basic Operations: Input (reading data), Process (calculations, assignments), Output


(displaying results).

9.2.2 Basic Constructs


Algorithms are built using three basic control structures:

• Sequence: Steps are executed one after another in the order they are written.

• Selection: A choice is made between different paths based on a condition (e.g., IF...THEN...ELSE,
CASE...OF).

• Iteration (Repetition): A block of steps is executed repeatedly (e.g., FOR...NEXT,


WHILE...DO...ENDWHILE, REPEAT...UNTIL).

43
9.2.3 Algorithm Representation
• Structured English: Using a limited subset of English words and indentation to describe
the algorithm’s logic steps.

• Flowchart: A diagrammatic representation using standard symbols (terminator, process,


input/output, decision) connected by flow lines to show the sequence and logic.

• Pseudocode: A text-based representation using keywords (like ‘INPUT‘, ‘OUTPUT‘,


‘IF‘, ‘FOR‘, ‘WHILE‘, ‘REPEAT‘), meaningful identifiers, and standard operators to de-
scribe the algorithm’s logic in detail, closer to actual code but language-independent.

9.2.4 Writing and Drawing Algorithms


• Be able to write pseudocode from a structured English description or a flowchart.

• Be able to draw a flowchart from a structured English description or pseudocode.

• Be able to document a simple algorithm using any of the three methods.

9.2.5 Stepwise Refinement


• The process of breaking down algorithm steps (from decomposition) into progressively finer
detail.

• Starts with high-level steps and refines each step into more detailed sub-steps until the level
of detail is sufficient to be directly translated into program code (or detailed pseudocode).

9.2.6 Logic Statements


Used within selection and iteration constructs to define conditions (e.g., ‘IF Mark < 40‘, ‘WHILE
Counter <= 10‘, ‘UNTIL Found = TRUE‘). Use relational operators (‘=‘, ‘<>‘, ‘<‘, ‘>‘, ‘<=‘,
‘>=‘) and logical operators (‘AND‘, ‘OR‘, ‘NOT‘).

44
10 Data Types and Structures
10.1 Data Types and Records (10.1)
10.1.1 Basic Data Types
Selecting appropriate data types is crucial for efficient storage and processing. Pseudocode
Data Types:
• ‘INTEGER‘: Whole numbers (positive, negative, zero).
• ‘REAL‘: Numbers with a fractional part.
• ‘CHAR‘: Single character.
• ‘STRING‘: Sequence of zero or more characters.
• ‘BOOLEAN‘: Logical values TRUE or FALSE.
• ‘DATE‘: Represents a calendar date.
• ‘ARRAY‘: Structure holding multiple elements of the same type (see 10.2).
• ‘FILE‘: Represents data stored externally (see 10.3).
Note: Programming languages have corresponding types (e.g., int, float/double, char, String,
boolean, Date classes).

10.1.2 Record Structures


• Purpose: A composite data type used to group related items of potentially different data
types under a single identifier. Represents a single entity’s attributes.
• Defining a Record Structure (Pseudocode):
TYPE TStudentRecord // Example record type name
DECLARE Name : STRING
DECLARE DateOfBirth : DATE
DECLARE ClassID : STRING
DECLARE AverageMark : REAL
ENDTYPE

• Declaring a Record Variable (Pseudocode): ‘DECLARE Pupil : TStudentRecord‘


• Accessing Record Fields (Pseudocode): Use dot notation: ‘identifier.fieldIdentifier‘
‘Pupil.Name <- "Alice"‘ ‘INPUT Pupil.AverageMark‘ ‘OUTPUT Pupil.ClassID‘
• Reading/Saving Data: Read data into individual fields, save data from individual fields.

10.2 Arrays (10.2)


A data structure holding a fixed number of elements of the same data type, accessed via an
index.

10.2.1 Array Terminology


• Index: Numerical value indicating the position of an element within the array.
• Lower Bound (LB): The index of the first element (often 0 or 1).
• Upper Bound (UB): The index of the last element.
• Element: An individual data item stored in the array.

45
10.2.2 1D Arrays (Lists)
• Declaration (Pseudocode): ‘DECLARE MyList : ARRAY[LB:UB] OF DATATYPE‘
Example: ‘DECLARE Scores : ARRAY[1:10] OF INTEGER‘

• Accessing Elements (Pseudocode): ‘MyList[index]‘ Example: ‘Scores[5] <- 100‘

10.2.3 2D Arrays (Tables)


• Represents data in rows and columns.

• Declaration (Pseudocode): ‘DECLARE MyTable : ARRAY[LBR:UBR, LBC:UBC] OF


DATATYPE‘ (LBR/UBR = Lower/Upper Bound Row, LBC/UBC = Lower/Upper Bound
Column) Example: ‘DECLARE Board : ARRAY[1:8, 1:8] OF CHAR‘

• Accessing Elements (Pseudocode): ‘MyTable[rowIndex, columnIndex]‘ Example: ‘Board[3,


4] <- ’Q’‘

10.2.4 Processing Array Data


• Linear Search: Sequentially checks each element from the lower bound until the item is
found or the upper bound is reached. Suitable for unsorted arrays.
// Pseudocode for Linear Search ( Simplified )
found <- FALSE
index <- lowerBound
REPEAT
IF MyList [ index ] = itemToFind THEN
found <- TRUE
ENDIF
index <- index + 1
UNTIL found = TRUE OR index > upperBound
IF found THEN
OUTPUT " Item found "
ELSE
OUTPUT " Item not found "
ENDIF

• Bubble Sort: Compares adjacent elements and swaps them if they are in the wrong order.
Repeats passes through the array, reducing the comparison range by one each time, until
no swaps occur in a pass or only one element remains unsorted. Sorts in place. Generally
inefficient for large datasets.
// Pseudocode for Bubble Sort ( Ascending )
top <- upperBound
REPEAT
swap <- FALSE
FOR index <- lowerBound TO top - 1
IF MyList [ index ] > MyList [ index + 1] THEN
// Swap elements
temp <- MyList [ index ]
MyList [ index ] <- MyList [ index + 1]
MyList [ index + 1] <- temp
swap <- TRUE
ENDIF
NEXT index
top <- top - 1

46
UNTIL swap = FALSE OR top = lowerBound // Optimization : stop if no
swaps or only 1 element left

10.3 Files (10.3)


Used for persistent storage of data. This section focuses on text files.

10.3.1 Need for Files


To store data permanently so it is not lost when the program ends or the computer is turned off.
Allows data to be reused later or shared between programs.

10.3.2 Handling Text Files (Pseudocode)


Text files consist of lines of characters.

• Opening a File: Prepare a file for reading or writing. ‘OPENFILE <filename> FOR
READ|WRITE|APPEND‘ (Filename is a string, e.g., "data.txt")

• Reading from a File: Read one line at a time into a string variable. File must be open
FOR READ. ‘READFILE <filename>, <stringVariable>‘

• Writing to a File: Write the content of a string variable as a line.

– ‘FOR WRITE‘: Overwrites existing content or creates a new file.


– ‘FOR APPEND‘: Adds data to the end of an existing file or creates a new file.

‘WRITEFILE <filename>, <stringVariable>‘

• Checking for End of File: Use the ‘EOF()‘ function which returns TRUE if the end
of the file has been reached during reading. ‘WHILE NOT EOF(<filename>) DO ...
ENDWHILE‘

• Closing a File: Release the file resource after finishing operations. Essential to ensure
data is saved correctly. ‘CLOSEFILE <filename>‘

10.4 Introduction to Abstract Data Types (ADT) (10.4)


10.4.1 ADT Concept
• A logical description of how data is viewed and the operations that can be performed on
it, without regard to how it will be implemented in memory.

• Defines a collection of data and a set of operations on that data (e.g., a Stack ADT has
data items and operations like push, pop, peek).

• Separates the logical properties from the implementation details.

10.4.2 Examples of ADTs


• Stack:

– Linear list following Last-In, First-Out (LIFO) principle.


– Operations: ‘Push‘ (add item to top), ‘Pop‘ (remove item from top), ‘Peek‘ (view
top item), ‘isEmpty‘, ‘isFull‘.
– Pointers: ‘basePointer‘ (fixed bottom), ‘topPointer‘ (moves with push/pop).

47
– Use Cases: Function call management, recursion backtracking, expression evaluation
(RPN).

• Queue:

– Linear list following First-In, First-Out (FIFO) principle.


– Operations: ‘Enqueue‘ (add item to rear), ‘Dequeue‘ (remove item from front),
‘Peek‘ (view front item), ‘isEmpty‘, ‘isFull‘.
– Pointers: ‘frontPointer‘, ‘rearPointer‘.
– Use Cases: Print queues, keyboard buffers, scheduling (CPU, disk), simulations.
Often implemented as a circular queue in arrays.

• Linked List:

– Dynamic data structure where items (nodes) are linked using pointers. Each node
contains data and a pointer to the next node.
– Allows efficient insertion and deletion compared to static arrays (no need to shift
elements).
– Size can grow or shrink dynamically (limited by available memory).
– Pointers: ‘startPointer‘ (points to first node), pointers within each node, null pointer
for last node. Requires management of free nodes (heap).
– Operations: Insert node, delete node, find node, traverse list.
– Use Cases: Implementing other ADTs (stacks, queues), dynamic memory allocation,
situations where list size changes frequently.

10.4.3 Using ADTs


Ability to conceptually add, edit, and delete data from these structures is required, but writing
the implementation pseudocode (like stack push/pop) is not expected at AS Level.

10.4.4 Array Implementation


• Stack: Use a 1D array. ‘basePointer‘ usually fixed at index 0 or 1. ‘topPointer‘ is an
integer index moving up/down the array. Check for array bounds (‘isFull‘, ‘isEmpty‘).

• Queue: Use a 1D array, often managed as a circular queue to avoid data shifting.
‘frontPointer‘ and ‘rearPointer‘ are integer indices that wrap around the array bounds.
Need to track ‘queueLength‘ or use other methods to distinguish full from empty.

• Linked List: Can use two parallel 1D arrays: one for data, one for pointers (indices of the
next element). Requires managing a list of free nodes (heap), often using another linked
list structure within the arrays. ‘startPointer‘ and ‘heapPointer‘ are integer indices. Null
pointer represented by a special value (e.g., -1 or 0).

48
11 Programming
Focuses on implementing algorithms using pseudocode constructs.

11.1 Programming Basics (11.1)


11.1.1 Implementing Designs
Ability to translate a design (flowchart, structured English) into pseudocode.

11.1.2 Pseudocode Statements


• Declaration and Initialisation:

– Constants: ‘CONSTANT Identifier = Value‘ (Value assigned at declaration)


– Variables: ‘DECLARE Identifier : DATATYPE‘ (Initial value often assigned sepa-
rately, e.g., ‘Counter <- 0‘)

• Assignment: Assigning a value or the result of an expression. ‘Identifier <- Value‘ or


‘Identifier <- Expression‘

• Expressions: Using arithmetic (‘+‘, ‘-‘, ‘*‘, ‘/‘, ‘∧ ‘, ‘DIV‘, ‘MOD‘) or logical (‘AND‘,
‘OR‘, ‘NOT‘) operators. Parentheses control evaluation order.

• Input/Output:

– ‘INPUT Identifier‘ (Read value from keyboard)


– ‘OUTPUT Expression‘ or ‘OUTPUT "Literal string", Variable‘ (Display to console)

11.1.3 Built-in Functions and Library Routines


• Use predefined functions provided by the language/pseudocode standard.

• String Manipulation (Examples):

– ‘LENGTH(string)‘: Returns number of characters.


– ‘LEFT(string, n)‘: Returns leftmost n characters.
– ‘RIGHT(string, n)‘: Returns rightmost n characters.
– ‘MID(string, start, length)‘: Returns substring.
– String concatenation uses ‘&‘.

• Other functions like ‘INT()‘, ‘RAND()‘, ‘EOF()‘ etc. will be provided if needed and not
standard.

11.2 Constructs (11.2)


Control structures for selection and iteration.

49
11.2.1 Selection
• IF Statement: For single or two-way choices.
// Single choice
IF < condition > THEN
< statements >
ENDIF

// Two - way choice


IF < condition > THEN
< statements for TRUE >
ELSE
< statements for FALSE >
ENDIF

// Nested IF
IF < condition1 > THEN
< statements1 >
ELSE
IF < condition2 > THEN
< statements2 >
ELSE
< statements3 >
ENDIF
ENDIF

• CASE Statement: For multiple choices based on the value of a single variable/expression.
CASE OF < identifier >
< value1 > : < statement ( s ) >
< value2 > : < statement ( s ) >
< value3 .. value4 > : < statement ( s ) > // Range possible
...
OTHERWISE : < statement ( s ) > // Optional default
ENDCASE

11.2.2 Iteration (Loops)


• Count-Controlled Loop (FOR): Repeats a fixed number of times. Counter variable
automatically managed.
FOR < identifier > <- < startValue > TO < endValue > [ STEP < stepValue >]
< statements >
NEXT < identifier >
// STEP is optional , defaults to 1

• Post-Condition Loop (REPEAT...UNTIL): Condition checked *after* the loop body


executes. Loop body always executes at least once. Repeats *until* condition is TRUE.
REPEAT
< statements >
UNTIL < condition >

• Pre-Condition Loop (WHILE...DO): Condition checked *before* the loop body ex-
ecutes. Loop body may never execute if condition is initially FALSE. Repeats *while*
condition is TRUE.

50
WHILE < condition > DO
< statements >
ENDWHILE

11.2.3 Justifying Loop Choice


• Use FOR when the number of iterations is known beforehand.

• Use REPEAT...UNTIL when the loop must execute at least once, and the condition for
stopping is checked at the end (e.g., input validation).

• Use WHILE...DO when the loop might not need to execute at all, and the condition for
continuing is checked at the start (e.g., processing file data until EOF).

11.3 Structured Programming (11.3)


Using procedures and functions to create modular, well-organised code.

11.3.1 Procedures
• A named block of code performing a specific task. Does not return a value.

• Definition (Pseudocode):
PROCEDURE < identifier > [ ( [ BYVAL | BYREF ] < param1 >: < type > , ... ) ]
< statements >
ENDPROCEDURE
// Parameters are optional

• Calling (Pseudocode): ‘CALL <identifier> [ ( <argument1>, <argument2>, ... ) ]‘

• Appropriate Use: When a sequence of actions needs to be performed, possibly multiple


times, but no single value is calculated and returned.

• Parameters: Allow data to be passed into (and potentially out of) the procedure.

– Argument: The actual value/variable passed during the call.


– Parameter: The variable declared in the procedure header that receives the argu-
ment’s value.
– Pass by Value (BYVAL): A copy of the argument’s value is passed. Changes to
the parameter inside the procedure do *not* affect the original argument outside.
(Default if not specified).
– Pass by Reference (BYREF): The memory address of the argument is passed.
Changes to the parameter inside the procedure *do* affect the original argument
outside.

11.3.2 Functions
• A named block of code performing a specific task and returning a single value.

• Definition (Pseudocode):

51
FUNCTION < identifier > [ ( [ < param1 >: < type > , ...] ) ] RETURNS <
return_datatype >
< statements >
RETURN < value > // Must return a value of the specified type
ENDFUNCTION
// Parameters are optional

• Calling (Pseudocode): Used within an expression where its return value is needed.
‘MyVariable <- <identifier> ( [<argument1>, ...] )‘ ‘OUTPUT "Result is ", <identifier>
( [<argument1>, ...] )‘

• Appropriate Use: When a specific calculation needs to be performed that results in a


single value which is then used elsewhere.

• Parameters: Usually passed by value, as functions are primarily intended to calculate


and return a result, not modify external variables (though modifying globals or passing by
reference is possible, it’s often discouraged for functions).

11.3.3 Terminology
• Procedure/Function Header: The first line defining the procedure/function (e.g., ‘PRO-
CEDURE MyProc (BYREF Count : INTEGER)‘).

• Procedure/Function Interface: The header, defining the name, parameters (and their
types/passing mechanism), and return type (for functions). Defines how the module inter-
acts with the rest of the program.

• Parameter: Variable in the header.

• Argument: Value/variable passed in the call.

• Return Value: The single value returned by a function using the ‘RETURN‘ statement.

11.3.4 Efficient Pseudocode


Using procedures and functions appropriately to avoid code repetition, improve readability, and
make code easier to test and maintain.

52
12 Software Development
12.1 Program Development Life cycle (12.1)
A structured process for developing software.

12.1.1 Purpose of a Development Life Cycle


• Provides a systematic framework for planning, developing, testing, and maintaining soft-
ware.

• Helps manage complexity, ensures requirements are met, improves quality, facilitates team-
work, aids project management (time/cost estimation).

12.1.2 Different Development Life Cycles


Different models suit different types of projects and environments.

• Waterfall Model:

– Principles: Linear, sequential phases (Analysis -> Design -> Coding -> Testing ->
Maintenance). Each phase must be completed before the next begins. Emphasis on
documentation.
– Benefits: Simple, easy to manage, well-defined stages and deliverables.
– Drawbacks: Inflexible (difficult to go back and change requirements), working software
only produced late in the cycle, not suitable for complex or evolving projects.

• Iterative Model (e.g., Spiral, Agile variations):

– Principles: Develops system in repeated cycles (iterations). Each iteration builds


on the previous one, producing a working (though initially limited) version early.
Incorporates feedback.
– Benefits: More flexible to changing requirements, working software produced early
and frequently, easier to manage risk, better user feedback integration.
– Drawbacks: Requires good planning, can be harder to manage overall project scope/-
timeline, whole system architecture needs consideration early on.

• Rapid Application Development (RAD):

– Principles: Focuses on rapid prototyping and iterative development with heavy user
involvement. Often uses workshops, reusable components, and automated tools. De-
velopment phases may overlap or run in parallel.
– Benefits: Very fast development time, high user involvement leads to better fit, flexible
to changes.
– Drawbacks: Requires skilled teams and committed users, less emphasis on formal
documentation, may not scale well for very large systems, can lead to lower code
quality if rushed.

12.1.3 Stages in the Program Development Life Cycle


1. Analysis: Understanding and defining the problem. Gathering requirements, feasibility
study, producing a requirements specification.

53
2. Design: Planning the solution. Designing algorithms, data structures, user interface,
database schema. Producing design documentation (pseudocode, flowcharts, structure
charts, E-R diagrams, state-transition diagrams).

3. Coding (Implementation): Writing the program code in a suitable programming lan-


guage based on the design.

4. Testing: Finding and correcting errors. Includes module testing, integration testing,
system testing, alpha/beta testing, acceptance testing. Uses various test data types.

5. Maintenance: Modifying the software after release. Includes corrective (fixing bugs),
adaptive (adapting to new environments/requirements), perfective (improving performance/us-
ability).

12.2 Program Design (12.2)


Tools for documenting the design before coding.

12.2.1 Structure Charts


• Purpose: Hierarchical diagram showing the breakdown of a program into modules (pro-
cedures/functions). Illustrates module relationships and calling structure.

• Construction: Modules represented by rectangles. Lines show calls between modules.


Arrows alongside lines indicate parameters passed (data couples) or flags returned (con-
trol couples). Loops and decisions can be indicated with annotations (e.g., diamond for
selection, curved arrow for iteration).

• Deriving Pseudocode: Each box in the structure chart typically corresponds to a PRO-
CEDURE or FUNCTION definition in pseudocode. Parameters shown on the chart map
to the parameters in the pseudocode headers/calls.

12.2.2 State-Transition Diagrams


• Purpose: Document the behaviour of a system that can be in one of a finite number of
states (a Finite State Machine - FSM). Shows how the system transitions from one state
to another based on events/inputs.

• Components:

– States: Represented by circles/nodes.


– Transitions: Represented by directed arrows between states.
– Events/Inputs: Labels on the transitions causing the state change.
– Conditions: Optional conditions (in square brackets) on transitions.
– Outputs/Actions: Optional actions performed during a transition (often shown after
a ’/’).
– Start State: Indicated by an arrow pointing into it from nowhere.
– Stop/End State(s): Sometimes indicated by double circles.

• State-Transition Table: Tabular representation showing current state, input/event, and


next state for all possibilities.

54
12.3 Program Testing and Maintenance (12.3)
12.3.1 Exposing and Avoiding Faults
• Faults (bugs) are inevitable in complex software.

• Good design practices (modular design, clear specifications) help avoid faults.

• Rigorous testing is essential to expose faults before release.

12.3.2 Types of Errors


• Syntax Errors: Errors in the grammar/rules of the programming language (e.g., mis-
spelled keywords, missing punctuation). Detected by the compiler/interpreter during trans-
lation. Program will not run.

• Logic Errors: Errors in the algorithm’s design. Program runs but produces incorrect or
unexpected results. Detected during testing by comparing actual output with expected
output. Harder to find, require debugging techniques (tracing, stepping).

• Run-time Errors: Errors occurring during program execution (e.g., division by zero, file
not found, array index out of bounds, memory overflow). May cause program to crash or
halt unexpectedly. Often detected by the OS or run-time environment.

Note: Correcting errors involves identifying the type and location, then modifying the code or
design.

12.3.3 Testing Methods


• Dry Run: Manually stepping through pseudocode or code using a trace table to track
variable values and logic flow. Done by the developer.

• Walkthrough: Formal review where developer explains code/design to colleagues, who


provide feedback and identify potential issues.

• White-box Testing: Testing based on knowledge of the internal structure and logic of
the code. Aims to test every path through a module. Done by developers.

• Black-box Testing: Testing based only on the specification (inputs and expected outputs)
without knowledge of the internal code structure. Tests if the module meets requirements
from a user perspective. Can be done by independent testers.

• Integration Testing: Testing interfaces and interactions between different modules/-


components after they have been individually tested (unit tested). Ensures modules work
together correctly.

• Stub Testing: Using dummy modules (stubs) that simulate the behaviour of undeveloped
modules during integration testing. Allows testing of module interactions before all modules
are complete.

• Alpha Testing: In-house testing of a near-complete product by internal staff (developers,


testers) before external release. Simulates real-world use.

• Beta Testing: Releasing a pre-release version to a limited number of external users (beta
testers) to get feedback and identify bugs in real-world environments before final release.

• Acceptance Testing: Final testing by the client/customer to ensure the software meets
the agreed requirements and specifications before formally accepting it.

55
12.3.4 Test Strategy and Test Plan
• Test Strategy: High-level document outlining the overall approach to testing (scope,
objectives, resources, schedule, types of testing).

• Test Plan: Detailed document specifying *what* will be tested, *how* it will be tested
(test cases, procedures), *who* will test it, and the expected results/pass criteria for specific
features or modules. Includes test data.

12.3.5 Test Data


Choosing appropriate data is crucial for effective testing.

• Normal Data: Sensible data within the expected range, that the program should accept
and process correctly.

• Abnormal (Erroneous) Data: Data outside the expected range or of the wrong type,
that the program should reject gracefully (e.g., with an error message).

• Extreme Data: Data at the boundaries/limits of the acceptable range. Tests edge cases.

• Boundary Data: Includes extreme data (at the limits) and data just outside the limits
(which should be rejected). Tests boundary conditions thoroughly.

12.3.6 Maintenance
Modifying software after its initial release.

• Need: Fix newly discovered bugs, adapt to changes in hardware/OS/regulations, improve


performance or usability, add new features.

• Types:

– Corrective Maintenance: Fixing errors (bugs) found after release.


– Adaptive Maintenance: Modifying software to work in a new environment (e.g.,
new OS version, new hardware, new regulations).
– Perfective Maintenance: Improving the software’s performance, usability, or main-
tainability without changing its core functionality (e.g., optimising code, improving
UI).
– (Enhancive Maintenance - sometimes considered part of perfective/adaptive): Adding
new features or functionality.

12.3.7 Analysing and Amending Existing Programs


Ability to read, understand, and modify existing code to enhance functionality or fix bugs, often
as part of maintenance. Requires understanding the original design and testing any changes
thoroughly.

56

You might also like