CS Notes
CS Notes
(Syllabus 2024-2025)
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
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
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.
• 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:
• an understanding of the component parts of computer systems and how they interrelate
(software, data, hardware, communication, people).
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 .
• 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 .
• 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).
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.
• 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)
• 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.
– 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).
• Extended ASCII: An 8-bit code (256 characters), adding graphics symbols and foreign
language characters. Not fully standardised.
Note: Students are expected to be familiar with these concepts but not memorise specific char-
acter codes.
• 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.
• 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
– 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.
• 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).
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.
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.
– 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.
– 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.
• Bus Topology:
• Star Topology:
• 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.
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.
• 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.
– 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.
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.
• 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.
• 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.
– 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).
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.
• Public IP Address: Globally unique address assigned by an ISP, directly reachable from
the internet.
– 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).
• 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.
• 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.
• 3D Printer: Creates physical objects layer by layer from a digital model. Methods include:
• 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).
• 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).
– Read/write capability.
– Volatile (data lost when power off).
– Holds OS, running applications, data currently in use.
– Types: DRAM, SRAM.
18
– Does not require refreshing.
– Faster, more expensive, lower density than DRAM.
– Used for CPU cache memory.
• EPROM (Erasable Programmable ROM): Can be erased (using UV light) and re-
programmed multiple times. Has a quartz window.
• 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:
• 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.
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.
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).
– 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.
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:
• 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).
• 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.
• 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.
• 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.
• 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.
1. Fetch:
2. Decode:
3. Execute:
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.
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.
• Assembler: A translator program that converts assembly language source code into ma-
chine code (object code).
• Pass 1:
• Pass 2:
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.
• 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).
• Logical Shift:
• Arithmetic Shift:
– 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).
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‘.
• ‘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.
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.
• 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.
• 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.
– 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.
• 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.
– 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.
• 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.
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.
• 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.
– 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.
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.
• 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.
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.
• 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.
• 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).
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.
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).
• Impacts:
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.
• 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.
• 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).
• 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.
– 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).
– 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.
– 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.
• Data Integrity Enforcement: Enforces constraints like primary keys, foreign keys (ref-
erential integrity), data types, validation rules.
• Backup and Recovery Procedures: Utilities to back up the database and restore it in
case of failure.
• 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.
• 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‘.
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:
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.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).
• 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).
• 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).
43
9.2.3 Algorithm Representation
• Structured English: Using a limited subset of English words and indentation to describe
the algorithm’s logic steps.
• 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).
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).
45
10.2.2 1D Arrays (Lists)
• Declaration (Pseudocode): ‘DECLARE MyList : ARRAY[LB:UB] OF DATATYPE‘
Example: ‘DECLARE Scores : ARRAY[1:10] OF INTEGER‘
• 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
• 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>‘
• 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>‘
• 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).
47
– Use Cases: Function call management, recursion backtracking, expression evaluation
(RPN).
• Queue:
• 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.
• 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.
• Expressions: Using arithmetic (‘+‘, ‘-‘, ‘*‘, ‘/‘, ‘∧ ‘, ‘DIV‘, ‘MOD‘) or logical (‘AND‘,
‘OR‘, ‘NOT‘) operators. Parentheses control evaluation order.
• Input/Output:
• Other functions like ‘INT()‘, ‘RAND()‘, ‘EOF()‘ etc. will be provided if needed and not
standard.
49
11.2.1 Selection
• IF Statement: For single or two-way choices.
// Single choice
IF < condition > THEN
< statements >
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
• 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
• 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.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
• Parameters: Allow data to be passed into (and potentially out of) the procedure.
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>, ...] )‘
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.
• Return Value: The single value returned by a function using the ‘RETURN‘ statement.
52
12 Software Development
12.1 Program Development Life cycle (12.1)
A structured process for developing software.
• Helps manage complexity, ensures requirements are met, improves quality, facilitates team-
work, aids project management (time/cost estimation).
• 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.
– 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.
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).
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).
• 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.
• Components:
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.
• 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.
• 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.
• 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.
• 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.
• 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.
• Types:
56