๐ป Year 10 Computer Science
GCSE Computer Science: CPU architecture, data representation, networks, cybersecurity, and programming.
CPU Architecture
Components of the CPU
- ALU (Arithmetic Logic Unit): performs arithmetic operations (addition, subtraction, multiplication, division) and logical operations (AND, OR, NOT, comparisons)
- CU (Control Unit): manages and coordinates the activities of the CPU; directs the flow of data between the CPU and other components; decodes instructions
- Registers: tiny, extremely fast storage locations inside the CPU. Program Counter (PC) holds the address of the next instruction. Accumulator (ACC) holds the result of calculations. Memory Address Register (MAR) holds the address of memory being read/written. Memory Data Register (MDR) holds data being read from or written to memory.
- Cache: small, fast memory between the CPU and RAM. Stores frequently used instructions and data. L1 cache (fastest, smallest, inside CPU), L2 and L3 (larger, slightly slower)
The Fetch-Decode-Execute Cycle (FDE Cycle)
- Fetch: the address in the PC is copied to the MAR. The instruction at that memory address is fetched into the MDR. The PC is incremented (ready for the next instruction). The instruction moves from MDR to the Current Instruction Register (CIR).
- Decode: the CU decodes the instruction in the CIR โ it interprets the opcode (what to do) and the operand (what data to use)
- Execute: the decoded instruction is carried out by the ALU or another part of the system
Factors Affecting CPU Performance
- Clock speed: the number of FDE cycles per second, measured in GHz. Higher clock speed โ faster processing (all else being equal).
- Number of cores: a multi-core CPU can execute multiple threads simultaneously. Dual-core, quad-core, octa-core. Performance gains depend on software being able to use multiple cores (parallelism).
- Cache size: a larger cache means more data is stored close to the CPU โ fewer slow RAM accesses โ faster overall performance
- Von Neumann architecture: most modern computers use this โ a single memory stores both data AND program instructions. The CPU fetches from this memory. An alternative is Harvard architecture (separate data and instruction memories), used in embedded systems.
Memory & Storage
Primary Storage
- RAM (Random Access Memory): volatile โ contents are lost when power is removed. Stores the operating system, currently running programs, and data in use. Faster and more expensive than secondary storage. Every running application loads from secondary storage into RAM.
- ROM (Read-Only Memory): non-volatile โ contents persist without power. Contains the BIOS/firmware โ the first program that runs when a computer starts up (bootstrap loader). Cannot be written to in normal operation.
- Virtual memory: when RAM is full, the OS uses a section of the hard drive as if it were RAM (a pagefile/swap space). Very slow compared to real RAM โ causes performance degradation.
Secondary Storage
- HDD (Hard Disk Drive): magnetic storage on spinning platters. Non-volatile. High capacity, low cost per GB. Slower than SSD (moving mechanical parts). Vulnerable to physical shock.
- SSD (Solid State Drive): flash memory. Non-volatile. Much faster than HDD. No moving parts โ more durable, lighter, quieter. More expensive per GB. Limited number of write cycles.
- Optical (CD, DVD, Blu-ray): laser reads/writes tiny pits and lands on a reflective disc. Non-volatile. Portable. Low capacity compared to magnetic/solid state. Slow. Used for distributing media and software.
- Cloud storage: files stored on remote servers accessed via the internet. Accessible from anywhere. Dependent on internet connection. Security and privacy concerns. Examples: Google Drive, OneDrive, iCloud, Dropbox.
Data Representation
Binary and Hexadecimal
- Computers work in binary (base 2) โ only two states: 0 and 1 (off and on). A bit is a single binary digit. A byte is 8 bits.
- Powers of 2: 2โท=128, 2โถ=64, 2โต=32, 2โด=16, 2ยณ=8, 2ยฒ=4, 2ยน=2, 2โฐ=1
- Convert binary to denary: write column values above each bit, sum the values of the columns containing a 1. 01101010 = 64+32+8+2 = 106
- Convert denary to binary: repeatedly divide by 2, write remainders in reverse order. 106 รท 2 โ 53 r0 โ 26 r1 โ 13 r0 โ 6 r1 โ 3 r0 โ 1 r1 โ 0 r1. Read remainders bottom up: 1101010. (Pad to 8 bits: 01101010)
- Hexadecimal (base 16): digits 0โ9 then A(10) B(11) C(12) D(13) E(14) F(15). One hex digit represents 4 bits (a nibble). Two hex digits represent 1 byte. Hex is compact โ shorter and more human-readable than long binary strings. Used in: colour codes (#FF5733), memory addresses, MAC addresses, debugging.
- Convert hex to binary: replace each hex digit with its 4-bit binary equivalent. 3A: 3=0011, A=1010 โ 00111010. Convert binary to hex: group into nibbles from the right, convert each nibble.
Characters, Images, and Sound
- ASCII: 7-bit code (128 characters). Each character has a unique binary code. Capital A = 65 (01000001), a = 97. Characters include letters, digits, punctuation, control codes. Extended ASCII uses 8 bits (256 characters).
- Unicode: 16-bit (UTF-16) or 8-bit variable (UTF-8). Covers over 1 million characters โ includes all world scripts, emoji, mathematical symbols. UTF-8 is compatible with ASCII for the first 128 characters.
- Images (bitmap): stored as a grid of pixels. Each pixel has a binary value for its colour. Colour depth: the number of bits per pixel (1 bit = 2 colours, 8 bits = 256 colours, 24 bits = 16.7 million colours โ "true colour"). Resolution: number of pixels (width ร height). File size = pixels ร colour depth (in bits). Metadata: additional data about the image (dimensions, colour depth, creation date).
- Sound: analogue sound waves are sampled at regular intervals. Sample rate: how many samples per second (Hz). Amplitude of each sample stored as a binary value. Bit depth: how many bits represent each sample's amplitude (8, 16, 24 bit). Higher sample rate + higher bit depth โ better quality but larger file size. CD quality: 44,100 Hz, 16-bit.
Data Compression
- Lossy compression: removes data permanently. Quality is reduced but file size can be dramatically smaller. Used for images (JPEG), audio (MP3), video (MP4/H.264). Not suitable for text or program files.
- Lossless compression: no data is lost โ the original file can be reconstructed perfectly. Algorithms find patterns and encode them more efficiently. Used for text files, program files, PNG images. ZIP, PNG, FLAC are lossless formats. Smaller size reduction than lossy.
- Run-length encoding (RLE): a simple lossless algorithm. Consecutive identical values are replaced with a count and value. 000000001111 โ 8ร0, 4ร1. Works well for images with large areas of the same colour (e.g. GIF).
Networks
Types of Network
- LAN (Local Area Network): covers a small geographic area (a building, a school, a home). Usually owned and managed by the organisation. Typically uses Ethernet cables or Wi-Fi.
- WAN (Wide Area Network): covers a large geographic area โ cities, countries, worldwide. The internet is the world's largest WAN. Uses public telecommunications infrastructure (telephone lines, fibre, satellite).
Network Hardware
- Router: connects different networks together (e.g. your home network to the internet). Forwards data packets between networks using IP addresses. Does NAT (Network Address Translation) to allow multiple devices to share one public IP.
- Switch: connects devices within the same LAN. Uses MAC addresses to direct data to the correct device. More intelligent than a hub (which broadcasts to all).
- Wireless Access Point (WAP): allows wireless devices to connect to a wired network. Often built into a home router.
- Network Interface Card (NIC): the hardware in each device that enables network communication. Each NIC has a unique MAC (Media Access Control) address โ the physical address.
Protocols
- Protocol: a set of rules that govern how data is transmitted between devices on a network. Both sender and receiver must follow the same protocol.
- TCP/IP: the foundation of the internet. IP (Internet Protocol) โ assigns addresses and routes packets. TCP (Transmission Control Protocol) โ ensures all packets arrive and are reassembled in order. Error checking and retransmission.
- HTTP/HTTPS: used to request and send web pages. HTTPS = HTTP + SSL/TLS encryption. Browsers use port 80 (HTTP) or 443 (HTTPS).
- DNS (Domain Name System): translates human-readable domain names (google.com) into IP addresses (142.250.180.46). Like a phone book for the internet. Hierarchical โ root servers, TLD servers (.com, .uk), authoritative servers.
- Packet switching: data is broken into small packets. Each packet travels independently across the network (possibly by different routes) and is reassembled at the destination. More efficient and resilient than circuit switching.
Cybersecurity
Common Threats
- Malware: malicious software designed to damage, disrupt, or gain unauthorised access. Types: virus (attaches to files, spreads when files are shared), worm (self-replicates across a network without needing a host file), Trojan (disguises itself as legitimate software), ransomware (encrypts files and demands payment), spyware (secretly monitors activity and steals data), adware (displays unwanted advertising).
- Phishing: fraudulent emails/messages that appear to come from a trusted source, designed to trick users into revealing passwords, personal information, or clicking malicious links. Spear phishing = targeted at a specific individual or organisation.
- Social engineering: manipulating people rather than technical systems. Includes phishing, pretexting (inventing a scenario to gain trust), baiting (leaving an infected USB drive), tailgating (physically following someone through a secure door).
- Brute force attack: trying every possible combination of passwords until the correct one is found. Effective against weak, short passwords. Countermeasure: account lockout after n failed attempts, long complex passwords.
- SQL injection: inserting malicious SQL code into a web form input field to manipulate the database. Can retrieve, modify, or delete data. Countermeasure: input validation, parameterised queries/prepared statements.
- DDoS (Distributed Denial of Service): overwhelming a server with traffic from many compromised computers (a botnet) until it cannot respond to legitimate requests.
Protective Measures
- Firewalls: monitor and filter incoming and outgoing network traffic based on security rules. Hardware (at network boundary) or software (on individual devices).
- Encryption: converts plaintext data into ciphertext using an algorithm and key. Only the intended recipient with the correct key can decrypt it. Symmetric encryption: same key for encrypt and decrypt. Asymmetric (public-key): different keys for each direction.
- Strong passwords: long, random, mix of characters, unique per account. Password managers allow this without needing to remember each one.
- Multi-factor authentication (MFA): requires two or more forms of identity verification โ something you know (password), something you have (phone/token), something you are (biometric). Greatly reduces risk of account takeover.
- Software updates and patching: software vulnerabilities are constantly discovered. Updates/patches fix known vulnerabilities. Outdated software is a major attack surface.
- Penetration testing: ethical hackers simulate attacks to identify vulnerabilities before malicious actors do. Bug bounty programmes.
- Access control: principle of least privilege โ users and programs should only have the access they need to do their job, no more.
Programming Fundamentals
Core Concepts
- Variables: named storage locations that hold a value. Value can change during execution. Must be assigned a name and a data type in some languages.
- Data types: integer (whole numbers), float/real (decimal numbers), string (text), boolean (True/False), character (single letter)
- Input/Output: print() outputs to the screen; input() reads from the keyboard (returns a string in Python โ must cast with int() or float() if needed)
- Casting: converting between data types. int("42") = 42. str(42) = "42". float("3.14") = 3.14
Selection and Iteration
# Selection (if/elif/else)
age = int(input("Age: "))
if age >= 18:
print("Adult")
elif age >= 13:
print("Teenager")
else:
print("Child")
# For loop (count-controlled)
for i in range(5):
print(i) # prints 0, 1, 2, 3, 4
# While loop (condition-controlled)
count = 0
while count < 5:
print(count)
count += 1
Subroutines (Functions and Procedures)
# Function: returns a value
def add(a, b):
return a + b
result = add(3, 5) # result = 8
# Procedure: does something, no return value
def greet(name):
print(f"Hello, {name}!")
greet("Alice")
- Parameters: variables in the function definition that receive the values passed in (arguments)
- Local vs global scope: variables defined inside a function are local โ they don't exist outside it. Global variables are defined at the top level and accessible everywhere. Avoid unnecessary global variables.
- Benefits of subroutines: avoids repetition (DRY โ Don't Repeat Yourself), makes code more readable and maintainable, can be tested independently, can be reused
Lists and File Handling
# Lists
names = ["Alice", "Bob", "Charlie"]
names.append("Dua")
names.remove("Bob")
print(names[0]) # Alice
print(len(names)) # 3
# File reading
with open("data.txt", "r") as f:
contents = f.read()
# File writing
with open("output.txt", "w") as f:
f.write("Hello world\n")
Algorithms & Pseudocode
Trace Tables
- A trace table tracks the value of each variable at each step of an algorithm. Used to verify correctness or identify bugs in pseudocode.
- Each row is one iteration or instruction. Each column is a variable or output. Work through the algorithm step by step, updating values as you go.
GCSE Pseudocode (OCR/AQA conventions)
x โ 10 // assignment
OUTPUT x // print
x โ USERINPUT // input
IF x > 5 THEN
OUTPUT "big"
ELSE
OUTPUT "small"
ENDIF
FOR i โ 1 TO 5
OUTPUT i
NEXT i
WHILE x > 0
x โ x - 1
ENDWHILE
FUNCTION add(a, b)
RETURN a + b
ENDFUNCTION
Standard Searching and Sorting
- Linear search: check each element one by one until found. O(n) โ may need to check all n elements in the worst case. Works on unsorted lists.
- Binary search: works only on sorted lists. Compare the middle element. If target is smaller, search the left half; if larger, search the right half. Repeat. O(log n) โ very efficient for large lists. 1,000 elements: max ~10 comparisons. 1,000,000 elements: max ~20 comparisons.
- Bubble sort: repeatedly compare adjacent pairs and swap if out of order. After one full pass, the largest element "bubbles" to the end. Repeat nโ1 times. O(nยฒ) โ slow but simple. Stable sort (maintains relative order of equal elements).
- Merge sort: divide the list in half repeatedly until individual elements remain. Then merge pairs of sorted sublists back together. O(n log n) โ much faster for large lists. Requires extra memory for the merge step.
- Insertion sort: build a sorted section from the left. Take the next unsorted element and insert it into the correct position in the sorted section. O(nยฒ) worst case but O(n) for nearly-sorted data. Efficient for small or nearly-sorted lists.