Fundamentals of Computer Systems

Learn the idea. Follow the example. Then try it yourself.

Read each section before opening its workbook activity. The language is written for a reader around age 15, while keeping the computing words you need for Unit 2.

Section A1 · Before the workbook

Computer parts and choosing devices

Your goal: Follow data through a computer and explain why different jobs need different hardware.

Input, processing, storage and output

Hardware is the physical equipment in a computer system. Input devices collect data: a microphone collects sound, a scanner reads an image and a sensor measures a condition. The processor follows instructions to work on that data. Storage keeps it for later. Output devices present a result or cause an action, such as a screen showing a message or a motor opening a gate. One device can do more than one job: a touchscreen is both input and output.

A library kiosk data pathScannerinputCPUprocessScreenoutputStorage keeps records; the network reaches shared records.
A library kiosk data path. Follow the labels as you read.

What is inside?

The CPU carries out instructions. RAM holds programs and data currently being used; its contents are normally lost when power is removed. An SSD or hard drive holds files between uses. The motherboard connects components. A graphics processor helps with image-related work. A network interface connects the device to a network. These parts must work together: adding a fast CPU will not fix a slow network connection.

Choose for the job

A mobile device is portable and runs from a battery. A desktop can offer a larger screen and more upgrade options. A server supports services used by other computers. A multifunction printer combines printing and scanning. Compare user needs, accessibility, performance, compatibility, power, cost and security. Include time for testing, moving files and training people.

Shared storage and recovery

NAS is storage that users reach over a network. RAID arranges several disks to improve speed or availability, depending on the level. RAID 1 mirrors data onto another disk. It can help after one disk fails, but accidental deletion can affect both copies. A separate backup, with a tested restore process, is still needed.

Worked example

A school editing computer has plenty of storage but struggles when several large programs are open. More RAM may help because more working data can stay in fast memory. First check the actual memory use; do not choose a part just because its number is bigger.

Pause and think

Why would a library kiosk need a scanner and a network connection?

Check your thinking

The scanner reads the book code. The network lets the kiosk look up or update the library record. Each part supports a different step.

Go deeper · A1

A closer look inside three kinds of computer

Every computer has the same basic jobs (input, processing, storage, output), but designers package the parts very differently depending on the job. Compare the three diagrams below and look for what changes: how easy parts are to replace, how much power they use, and how much is duplicated.

Labelled top-down view of a desktop motherboardMotherboard (the main circuit board)CPUunder the coolerM.2 SSDChipsetRear ports:USB, RJ45,HDMI, audioCPU socket:runs programinstructionsPCIe x16 slot:graphics cardM.2 slot:fast NVMe SSDRAM slots:working memory(volatile)24-pin powerfrom the PSUSATA ports:HDD / SSD /optical drivesChipset: routesdata betweenpartsCMOS battery keeps the clock and firmware settings
A desktop motherboard (simplified). Parts plug into standard slots, which is why desktops are easy to upgrade and repair.

A desktop PC is built from separate parts joined by the motherboard. Because the RAM, storage and graphics card sit in standard slots, a technician can upgrade or replace one part without replacing the whole computer. Laptops use similar parts, but many are soldered to the board to save space, so they are harder to upgrade.

Exploded view of the layers inside a smartphoneCover glass + touch digitiserinput: senses touchOLED display paneloutput: pixels make lightLogic boardSoC, RAM, flash storageBatterylithium-ion: limits run timeBack casecameras, antennas, charging coilSystem on a Chip• CPU cores (fast + efficient)• GPU (graphics)• NPU (AI tasks)• Image processor• Cellular modem (4G/5G)
Inside a smartphone. A System on a Chip (SoC) puts the CPU, GPU and other processors on one chip to save space and battery.

A phone must be thin, light and last all day on a battery. Instead of many separate chips, it uses a System on a Chip (SoC) that combines the CPU cores, graphics, an AI engine and the mobile modem. Storage is NAND flash, which is non-volatile and has no moving parts. Sensors such as the accelerometer, gyroscope, GPS receiver and proximity sensor are inputs that most desktop PCs do not have.

A server rack with redundant partsNetwork switchServer 1Server 2Server 3Storage array (RAID)Backup unitUPS: battery powerTwo power suppliesper server (A + B):one can fail safelyHot-swap drive bays:replace a failed diskwithout switching offTwo network linksto the switch, so onecable fault is survivableUPS keeps serversrunning long enoughto shut down cleanly
A small server rack. Servers use redundant (duplicated) parts because many people depend on them at once.

A server provides a service to many client computers at once, so a failure affects everyone. That is why servers have lots of RAM, many CPU cores, and redundant parts: two power supplies, two network connections and drives in a RAID array, often all in a rack with an uninterruptible power supply (UPS).

Why speed depends on the slowest part

The memory and storage hierarchyRegistersbytes · inside the CPUCacheMB · on the CPU chipRAMGB · volatile working memorySSDhundreds of GB–TB · no moving partsHDDTB · spinning plattersCloud / archiveunlimited · over the networkfaster, costs more per GBbigger, cheaper per GB
The memory hierarchy. Each level is slower but larger and cheaper than the one above, so computers copy the data they need upwards.

The CPU can only work on data that has been copied close to it. If data has to come from a slow hard disc or across a busy network, the fastest CPU still waits. This is called a bottleneck. When you recommend hardware, find the part that is holding the system back for that user, rather than simply choosing the biggest numbers.

Hard disc drive compared with solid state driveHard disc drive (HDD)Head must move to the track, then wait for it to spin roundSolid state drive (SSD)ControllerNANDNANDNANDNANDCacheAny location can be read directly: no moving parts
An HDD has a seek time because the head and platter must move. An SSD reads flash memory electronically, so it is faster, quieter and shock-resistant.
Hardware performance factors to compare when choosing parts
ComponentPerformance factorUnitBetter when…
CPUNumber of cores; clock speed; cache sizecores; GHz; MBmore cores help multitasking, higher GHz helps single tasks, bigger cache means fewer waits
RAMCapacity; speedGB; MT/senough GB to hold all open programs, otherwise the OS swaps to slow storage
HDDSeek time; spindle speed; transfer ratems; rpm; MB/slower seek time, higher rpm and transfer rate
SSDRead/write speed; interface (SATA or NVMe)MB/sNVMe SSDs can be several times faster than SATA ones
DisplayResolution; refresh rate; response time; brightness; contrastpixels; Hz; ms; cd/m²; ratiohigher refresh and lower response time give smoother motion
PrinterPrint speed; first page out; resolution; monthly duty cycleppm; s; dpi; pagesa higher duty cycle suits a busy office

Worked example: Does a faster drive matter?

  1. A video editor copies a 30 GB project (30,000 MB) to their computer.
  2. On a hard disc transferring at 150 MB/s: 30,000 ÷ 150 = 200 seconds (over 3 minutes).
  3. On an NVMe SSD transferring at 3,000 MB/s: 30,000 ÷ 3,000 = 10 seconds.
  4. For someone who opens large files many times a day, the SSD saves a lot of waiting. For someone who only writes documents, the difference is barely noticeable, so the money may be better spent elsewhere.

Always link the specification to what the user actually does.

Keeping data available: RAID and NAS

How RAID 0, 1 and 5 place data across drivesRAID 0: stripingA1A3A5A7Disk 1A2A4A6A8Disk 2fast, but no protectionRAID 1: mirroringA1A2A3A4Disk 1A1A2A3A4Disk 2survives one failure; half the spaceRAID 5: striping + parityA1B1C1PdDisk 1A2B2PcD1Disk 2PaPbC2D2Disk 3survives one failure; parity is spread
RAID levels. Orange blocks hold parity: extra data calculated from the other blocks, so a lost block can be rebuilt. RAID is not a backup.

A NAS (network attached storage) is a small computer whose only job is to share its drives over a network. It usually contains two or more drives in a RAID array, so that one drive failing does not lose the files. Remember the difference: RAID keeps a system running when a disc fails; a backup lets you recover from deletion, ransomware, theft or fire.

Key terms

Volatile
loses its contents when the power is switched off (RAM).
Non-volatile
keeps its contents without power (SSD, HDD, flash memory).
System on a Chip (SoC)
a single chip containing the CPU, graphics and other processors, used in phones and tablets.
Seek time
the time an HDD’s head takes to move to the right track.
Bottleneck
the slowest part of a system, which limits the speed of the whole system.
Redundancy
duplicate parts that take over when one fails.
UPS
uninterruptible power supply: a battery that keeps equipment running during a power cut.
Parity (RAID)
extra data calculated from other blocks, used to rebuild a failed drive’s data.

Think it through

Why does a tablet use flash storage rather than a hard disc?

Flash has no moving parts, so it survives being dropped, uses less battery, is silent and fits in a thin case. It is also faster to access.

A shop’s till server has one power supply and one disc. Name two single points of failure and a fix for each.

The power supply (fit two redundant PSUs, plus a UPS) and the disc (use RAID 1 or RAID 5, and keep a separate backup).

A gamer buys a very powerful graphics card but keeps an old 60 Hz monitor. What limits the experience?

The monitor. It can only show 60 frames per second, so frames the card draws above that are never seen. This is a bottleneck.

In the real world: a hospital

A hospital’s patient-record servers sit in a rack with redundant power, RAID storage and a UPS backed by a generator, because doctors need the records at any hour. Nurses on wards use cheaper thin clients or tablets, because the data and processing live on the servers.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

From your lessons · A1

Extra detail from your teacher’s Unit 2 lessons. Practise it on the Diagram tasks page.

Ports and connectors

Common ports and connectors
ConnectorWhereWhat it does
USB-A / USB-Cexternal portdata and power for keyboards, drives, phones; USB-C is reversible and can carry video and charging
HDMI / DisplayPortexternal portdigital video and audio to a monitor or TV
VGA / DVIexternal port (older)video to monitors: VGA is analogue, DVI digital
RJ45external portwired Ethernet network cable
3.5 mm audio jackexternal portheadphones, speakers, microphone
24-pin ATXinternalmain power from the power supply to the motherboard (older boards used 20-pin)
4/8-pin EPS (ATX12V)internalextra 12 V power for the CPU
6/8-pin PCIe powerinternalextra power for a graphics card
SATA data and SATA powerinternalconnect hard drives, SSDs and optical drives
Molex and Berginternal (legacy)older drive power; Berg was for floppy drives
M.2 slotinternalfast SSDs mounted straight onto the motherboard

Servers and their functions

A server provides services to many clients at the same time
ServerFunction
File serverstores shared files and controls who can open them
Print serverqueues print jobs and shares printers between users
Web serverstores web pages and sends them to browsers
Mail serversends, receives and stores email
Database serverruns a database that many users query at once
Application serverruns shared software for clients
Authentication / directory serverchecks usernames and passwords and holds user accounts
DHCP / DNS servergives devices IP addresses / turns names into IP addresses
RAID, NAS and SAN compared (a NAS often uses RAID inside)
RAIDNASSAN
What it isseveral disks combined inside one systema storage device on the networka separate high-speed network of storage
Used forspeed, capacity or fault tolerance (RAID 0, 1, 5)shared files, backups and media in homes and small businessesservers in data centres needing fast shared block storage
Accessed bythe one computer or server it is inmany devices using file protocols (SMB, NFS)servers, as if the storage were their own disks

Factors affecting the choice of hardware

Use these factors to justify a recommendation in exam answers
FactorQuestion to ask
User experienceis it easy to use, fast enough and reliable for this user?
Needs of the userwhat tasks: office work, gaming, video editing, field work?
PerformanceCPU, RAM, storage speed and graphics for the workload
Costpurchase, running and maintenance costs against the budget
Compatibilitydoes it work with existing software, peripherals and the network?
Efficiencypower use, heat and battery life
Implementationtime, training and disruption to install it
Productivitywill it help people work faster or better?
Securityencryption, biometrics, ability to lock or wipe it
Portability and connectivitysize, weight, Wi-Fi, 4G/5G, ports
Characteristics of mobile devices
Mobile deviceTypical featuresTypical use
Smartphonetouchscreen, cellular data, GPS, cameras, many sensorscalls, apps, navigation, payments
Tabletlarger touchscreen, long battery, often Wi-Fi onlyreading, media, sales demonstrations, note taking
Laptopkeyboard, more powerful CPU and storage, full OSoffice work, programming, editing
Sat-navGPS receiver, maps stored, dashboard mountroute guidance in vehicles
Wearabletiny screen, sensors (heart rate), Bluetooth to a phonefitness tracking, notifications

Key terms

Connector
the physical plug or socket that joins a cable to a device.
Server
a computer that provides services to many clients.
NAS
network attached storage: a storage device shared over the network.
SAN
storage area network: a dedicated fast network of shared storage for servers.

Think it through

Why does a graphics card need its own PCIe power connector?

Powerful GPUs need more power than the PCIe slot can supply, so extra 12 V power comes directly from the power supply.

A small office wants shared storage for six staff and nightly backups. NAS or SAN?

NAS: it is cheaper, easy to set up and shares files over the existing network; a SAN is for data centres.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why does a computer need ROM as well as RAM?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Which storage would you choose for a tablet, and why?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Name three embedded systems in a car.

Open on YouTube ↗

An animated explainer of the RAID levels your teacher covers with NAS and SAN.

Watch and think:

  • Which RAID level gives no protection at all?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What does a NIC do?

Open on YouTube ↗

Section A2 · Before the workbook

Operating systems and programs

Your goal: Explain how an operating system connects programs, users and hardware.

The operating system is the organiser

An operating system (OS) manages resources so programs can run. Its kernel is the central part that controls important operations. It gives programs CPU time, manages memory, handles interrupts and works with device drivers. Drivers translate requests into operations a device understands. File systems organise files on storage. Privileged kernel mode lets trusted OS code perform operations that ordinary programs cannot perform directly.

The OS connects applications and hardwareApplicationasks to printOS kernel and drivermanage and translate requestPrinterhardware
The OS connects applications and hardware. Follow the labels as you read.

Sharing and protecting resources

On a multitasking system, several tasks appear to run together because the processor switches between them or uses several cores. A multi-user OS also separates users and their permissions. A real-time OS must respond within a stated deadline; being fast on average is not enough. The OS also supports network connections and security, such as sign-in and file access rights.

Choose an interface

A graphical interface uses windows, icons and buttons. A command line uses typed instructions and can make repeated tasks easy to automate. A menu offers a limited set of choices. A ticket machine may use menus because people need a few clear options. An administrator might use commands to rename hundreds of files.

Different kinds of software

Applications help users do work, such as editing a video. Utilities maintain or protect the system, such as backup tools. Open-source licences allow access to source code under stated conditions. Open source does not automatically mean no cost, no security problems or free support. Choose software using compatibility, support, accessibility, performance and the needs of users.

Worked example

When you print a page, the application sends a request. The OS manages the print job, and a driver helps communicate with the printer. If the printer reports that it has no paper, the system must handle that event.

Pause and think

Why might a shop till use a menu instead of a full desktop?

Check your thinking

A menu can make common actions easier to find and limit mistakes. It must still support the tasks and accessibility needs of the staff.

Go deeper · A2

What the operating system is really doing

Layers of software between the user and the hardwareUserApplication software: browser, word processor, gameUtility software: antivirus, backup, compression, disk toolsOperating systemSchedulerMemory managerFile systemDevice driversNetworking + securitykernelHardware: CPU, RAM, storage, screen, network card
The operating system sits between programs and hardware. Programs ask the OS for resources rather than controlling the hardware directly.

The kernel is the part of the operating system that is always running. It decides which program uses the CPU next (scheduling), gives each program its own area of memory, reads and writes files through the file system, and talks to hardware through device drivers. Programs run in a restricted user mode; only the kernel runs in the privileged kernel mode, so a crashing app cannot take the whole computer down.

Timeline of multitasking with time slices and an interruptCPU time →ABCAKeyBCAKeyboard interrupt: the kernel pauses the current task,runs the keyboard handler, then carries onA = music player · B = word processor · C = file download
Multitasking: the scheduler gives each program a short time slice in turn, so fast that they all seem to run at once.

An interrupt is a signal that asks the CPU for attention: a key press, a network packet arriving, or a disc finishing a read. Instead of checking every device constantly, the CPU gets on with its work until an interrupt arrives. The kernel then runs the matching interrupt handler and returns to what it was doing.

Virtual memory: pages moved between RAM and storageRAM (fast, limited)P1P2Q1P3Q2R1P4Page file on SSD/HDD (slow)R2Q3P5R3pages swappedIf too many pages keep swapping, the computer slows down badly (thrashing).Adding RAM is the fix.
Virtual memory lets programs use more memory than the RAM holds, by keeping less-used pages on storage.
Types of operating system
Type of OSWhat it doesExample use
Real-time (RTOS)Guarantees a response within a fixed time limitcar airbags, aircraft controls, factory robots
Single-user, single-taskOne user runs one program at a timea simple embedded controller or early handheld device
Single-user, multi-taskingOne user runs many programs at oncea laptop or phone
Multi-userMany users share one computer’s resources at once, with separate accounts and permissionsa school file server or a web server
Choosing a user interface
InterfaceStrengthsWeaknessesSuits…
Graphical (GUI)easy to learn; visual; mouse or touchneeds more memory and processing; slower for repetitive jobsmost everyday users
Command line (CLI)fast for experts; scripts can automate jobs; uses few resourcescommands must be remembered; easy to make serious mistakestechnicians and servers
Menu-basedlimited choices, so few errors; quick to traininflexible; deep menus can be slowtills, ATMs, kiosks, TVs

Utility and application software

Utility software looks after the computer itself: antivirus and firewalls protect it, backup tools copy data, disc tools clean up and (for hard discs) defragment, compression tools make files smaller and encryption tools protect data. Application software helps a person do a task, such as writing, calculating, editing video or booking appointments.

Proprietary versus open-source software
Proprietary (closed source)Open source
Costusually a licence feeusually free to use
Source codesecret; only the company can change itpublished; anyone can read, change and share it under its licence
Supportpaid helpdesk and guaranteed updatescommunity forums, or paid support from a third party
Customisingonly the settings the company allowscan be changed to fit exact needs, if you have the skills

Key terms

Kernel
the core of the OS that manages the CPU, memory, files and devices.
Device driver
software that lets the OS control a particular piece of hardware.
Interrupt
a signal that makes the CPU pause and deal with an event.
Scheduler
the part of the kernel that decides which program runs next.
Virtual memory
using storage as extra, slower memory when RAM is full.
File system
the method the OS uses to organise files on a drive (e.g. NTFS, ext4, APFS).

Think it through

Why can a single-user multitasking OS not be used to control a car’s airbag?

It shares the CPU between many tasks and cannot guarantee how quickly it will respond. An airbag needs a real-time OS that always reacts within milliseconds.

A laptop with 4 GB of RAM becomes very slow when 20 browser tabs are open. Explain why.

The tabs need more memory than the RAM holds, so the OS keeps swapping pages to the drive. Storage is far slower than RAM, so the computer spends its time moving pages instead of working.

Give one reason a technician might prefer a command line to a GUI.

They can write a script that repeats a job, such as creating 200 user accounts, automatically and exactly the same way each time.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

From your lessons · A2

Extra detail from your teacher’s Unit 2 lessons. Practise it on the Diagram tasks page.

User, shell, kernel and hardwareUser: you and your applicationsShell: the interface: GUI, command line or menusKernel: the core of the OS: memory, CPU time, devices, filesHardware: CPU, RAM, storage, ports, network cardrequestsand results
Programs never talk to hardware directly: requests pass through the shell and kernel, which decides how hardware is used.
The role of the kernel in controlling and managing system components and tasks
Kernel jobWhat it does
Program executionloads programs and passes their requests to the CPU as system calls
Interrupt handlingdecides which signals need immediate attention and makes the CPU deal with them first
Memory managementgives each program its own memory and stops programs overwriting each other
Process schedulingshares CPU time between running programs
Device managementcontrols hardware through device drivers
File managementorganises files and folders and controls access to them
The operating system’s role in networking and security
At homeIn an organisation
Network typeusually peer-to-peer: no servers; share the internet and a printerclient–server: servers control resources and user accounts
How the OS manages securitypower-on or login passwords, Wi-Fi (WPA2/WPA3) password, passwords on shared foldersusers authenticate at login; access rights decide which files, printers and systems each user may reach; audit logs
Sharing resourcessimple file and printer sharingprint queues, network storage shown as normal drives, managed LAN and WAN access
Factors affecting the choice of user interface: the user, the device, the task and the environment
InterfaceGood forLimitations
Graphical (GUI)most users; touchscreens; visual tasksuses more memory and processing power
Command line (CLI)technicians, servers, automation with scriptscommands must be learned; easy to make mistakes
Menu-basedkiosks, ATMs, simple devicesonly the choices on the menu
Natural language / voicehands-free use, accessibilitycan misunderstand; needs a quiet place

When choosing an operating system, consider: the hardware it must run on, the software and devices it must support, the users’ skills, cost and licensing, security and updates, and whether it needs to be a network, real-time or mobile OS.

Principles and implications of open source software
Open sourceProprietary (closed source)
Source codepublished; anyone can study, change and share itkept secret by the company
Costoften free to uselicence fees
Supportcommunity forums, or paid support from companiesofficial support from the vendor
Implicationscan be customised; bugs can be found and fixed by many people; may need in-house skillsconsistent, supported product; locked to the vendor’s decisions and prices
ExamplesLinux, Android (base), LibreOffice, FirefoxWindows, macOS, Microsoft 365

Disk cache

A disk cache keeps recently and frequently used data from a drive in fast memory (part of RAM, or a chip on the drive). The next time that data is needed it is read from the cache instead of the slower drive. Writes can also be collected in the cache and written to the drive later, which is faster but risks losing data if the power fails before they are saved.

Key terms

Kernel
the core of the operating system that manages hardware, memory and CPU time.
Shell
the part of the OS the user interacts with: a GUI or command line.
Open source
software whose source code is published so others can study, change and share it.
Disk cache
fast memory holding recently used disk data to speed up access.

Think it through

Why does a server often use a command-line interface?

It needs fewer resources than a GUI, and administrators can automate tasks with scripts and manage it remotely.

Give one benefit and one drawback of open source for a school.

Benefit: free to install on every PC. Drawback: staff may need extra training, and support relies on the community or a paid partner.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • List four jobs of an operating system.

Open on YouTube ↗

What the kernel does and why it sits between programs and hardware.

Watch and think:

  • Why can’t applications talk to hardware directly?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Give two utilities and the problem each solves.

Open on YouTube ↗

The principles of open source software and why organisations use it.

Watch and think:

  • Give one benefit and one risk of open source for a business.

Open on YouTube ↗

Section A3 · Before the workbook

Collecting and using data

Your goal: Turn collected data into useful information and plan recovery.

Collect data carefully

Hardware collects data through sensors, scanners and keyboards. Software controls forms, records readings and applies checks. Validation checks whether an input follows rules. A range check might allow an age from 0 to 120. A type check might require a whole number. These checks can reject impossible values, but cannot prove that an accepted value is true.

Data becomes a reportCollect12, 15, 18Aggregatetotal = 45Report45 visitsValidation checks rules; it does not prove the count is true.
Data becomes a report. Follow the labels as you read.

Six processing jobs

Sorting puts records into an order. Aggregation combines values, for example a daily total. Analysis looks for patterns or meaning. Conversion changes a representation or format. Reporting presents information for an audience. Validation checks rules. Several of these jobs may happen in one system: a shop can check prices, sort sales by date, total them and show a weekly report.

Share data between systems

Sharing can improve access and reduce repeated typing. It also creates problems: two sites may change the same record, a network may fail, or someone may receive more access than they need. Decide which system holds the main record, how updates are kept in step and who can read or change each field. Include training, cost and time when introducing the system.

Prepare for loss

A backup is a recoverable copy. An archive keeps records for longer-term reference. A recovery plan explains what to restore, where the copy is stored, who does the restore and how to check it. Test restoration: a message saying a backup finished does not prove that the files can be recovered.

Worked example

A club counts 12, 15 and 18 visitors. Aggregation gives 45 visits. Analysis could compare this with last week. A report could show a chart. A validation rule of 0–100 would accept all three counts, even if one had been typed incorrectly.

Pause and think

How would you test a backup without risking live files?

Check your thinking

Restore a sample into a separate test location, open it and compare it with the expected original. Record whether the restore worked.

Go deeper · A3

From raw data to useful information

The stages of data processing from collection to reportCollectsensors, forms,barcodes, RFIDValidatecheck it followsthe rulesSortput into auseful orderAggregatecombine intototals/averagesAnalysefind patternsand trendsReportcharts, tables,dashboardsConversion can happen at any stage, e.g. analogue to digital, or CSV to a database table.
A typical data processing pipeline. Each stage turns raw data into something more useful.

Data is collected by hardware such as sensors, barcode scanners, RFID readers, card readers, cameras and keyboards, and by software such as online forms, apps that log activity, and systems that import data from other systems. Automatic collection (a sensor or scanner) is fast and avoids typing errors; manual collection (a person typing) is flexible but slower and error-prone.

A sensor-based control system for a greenhouseTemperaturesensorADCanalogue → digitalMicrocontrollercompares withtarget 24 °CActuatorheater / ventClouddashboardreadings sent every minuteFeedback: the greenhouse temperature changes, and the sensor measures it again
A control system. Sensors collect data, the program decides, actuators act, and feedback repeats the loop.
Common validation checks
Validation checkWhat it checksExample
Presencesomething has been enteredemail cannot be left blank
Typethe right kind of dataage must be a whole number
Rangebetween set limitsyear group from 7 to 13
Lengththe right number of charactersUK mobile number has 11 digits
Formatmatches a patternpostcode like LS1 4AP
Lookupis in a list of allowed valuescourse code exists in the course table
Check digita calculated digit matchesthe last digit of a barcode or ISBN

Validation stops impossible data, but it cannot tell whether data is true. Verification checks that data was copied correctly, for example by typing a password twice or by a person comparing the screen with the paper form.

Worked example: Multi-level sort, then aggregation

  1. A school has attendance records with a tutor group, a surname and minutes late.
  2. Sort first by tutor group, then by surname within each group, so each tutor sees their own list in alphabetical order.
  3. Aggregate: total the minutes late for each tutor group, and count the students late more than 3 times.
  4. Analyse: compare this month’s totals with last month’s to spot a trend.
  5. Report: a bar chart per tutor group, sent automatically to heads of year every Monday.

Sorting and aggregation turn thousands of rows into a few facts someone can act on.

Data stored across more than one system

Using and storing data across multiple computer systems
ImpactBenefitsProblems
Accessstaff at every site see the same recordsneeds a working network; remote access must be secured
Costless duplicated hardware at each sitelinks, cloud fees, licences and support
Implementationone agreed system and formatmigrating and merging old data; training; downtime
Productivityno phoning other sites or re-typing dataslow if the link is slow; version conflicts
Securitycentral backups and consistent access controlmore ways in for attackers; one breach exposes more data
Full, incremental and differential backups over a weekSunMonTueWedThuIncrementalDifferentialFullFullMonMonTue onlyMon→TueWed onlyMon→WedThu onlyMon→ThuEach backs up only what changed since the previous backup: quick to make, but a restore needs the full backup plus every incremental.Each backs up everything changed since the full backup: grows each day, but a restore needs only the full backup plus the latest one.3-2-1 rule: 3 copies of the data, on 2 kinds of media, with 1 copy off-site.
Backup strategies. The choice trades time and space for making backups against the time and effort to restore.

Key terms

Validation
an automatic check that data is reasonable and follows the rules.
Verification
a check that data has been entered or copied accurately.
Aggregation
combining many records into totals, counts or averages.
Actuator
a device that acts on the world, such as a motor, heater or valve.
ADC
analogue-to-digital converter: turns a sensor’s continuous signal into numbers.
Incremental backup
copies only the data changed since the last backup of any kind.

Think it through

Why is a range check on a date of birth not enough to stop mistakes?

A date can be inside the range but still wrong, e.g. 12/03 typed instead of 03/12. Verification (such as confirming with the person) is needed as well.

On Friday the server fails. Using incremental backups, which backups are needed to restore it?

Sunday’s full backup, then Monday’s, Tuesday’s, Wednesday’s and Thursday’s incrementals, applied in order.

Give one advantage of collecting data with a sensor instead of a person.

It can take readings continuously, day and night, at exact intervals, without typing errors or getting tired.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why store data in a database instead of a spreadsheet?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Which model suits a school sharing data across many PCs?

Open on YouTube ↗

Section B1 · Before the workbook

Ways to build a computer system

Your goal: Compare architecture models and choose one for a situation.

Instructions are stored too

In a stored-program computer, instructions are kept in memory so the CPU can fetch them. In the simple Von Neumann model, instructions and data share memory and a transfer path. They can compete for that path. In the Harvard model, instruction and data storage have separate paths, allowing some transfers to happen at the same time. Real processors may combine ideas from both models.

Simplified memory reads in Von Neumann and Harvard modelsVon NeumannCPUMemorydata + codeShared pathHarvardCPUCode memoryData memory
Simplified memory reads in Von Neumann and Harvard models. Follow the labels as you read.

Several computers working together

A cluster is a group of computers working together. It may share a large task or keep a service available when one computer fails. The computers must exchange information, which adds delay and management work. A cluster helps only if the software and task can use it well.

Where memory is matters

UMA means uniform memory access: processors have broadly similar access times to shared memory. NUMA means non-uniform memory access: a processor can access some memory faster than memory connected farther away. A program that keeps its data near the processor using it can benefit from locality.

Running an older system

Emulation makes one system behave like another. A museum may use it to run an old game. The emulator has to reproduce the behaviour expected by the program, including relevant hardware. Compatibility and performance can limit success. Choose architecture using the workload, memory access, reliability, energy and cost.

Worked example

A ticket service may divide requests across a cluster. If the database is the slow part and every request waits for it, adding more web computers may not fix the problem. Identify the bottleneck first.

Pause and think

Does a cluster always make one program run faster?

Check your thinking

No. Work must be divided effectively, and communication or shared resources can become a limit.

Go deeper · B1

Two ways to connect the CPU to memory

Von Neumann and Harvard architectures comparedVon NeumannCPUControl unitALURegistersone shared busMemoryinstructions AND dataOnly one fetch at a time: the von Neumann bottleneckHarvardCPUControl unitALURegistersbus 1bus 2InstructionmemoryDatamemoryInstruction and data fetched at the same time
Von Neumann (left) shares one memory and bus. Harvard (right) keeps instructions and data apart, each with its own bus.

In the stored program model, the program is held in memory just like data, so a computer can switch jobs simply by loading a different program. Early computers were rewired or re-switched for each new task. In a von Neumann machine, instructions and data share one memory and one bus, which is simple and flexible. In a Harvard machine they are separate, so the next instruction can be fetched while data is being read. Small controllers such as those in microwaves, washing machines and Arduino-style boards often use Harvard designs; modern PC processors mix both, with separate instruction and data caches in front of one main memory.

Many processors working together

A computer cluster sharing one big jobHead nodesplits job, collects resultsNetwork switchNode 1CPU + own RAMNode 2CPU + own RAMNode 3CPU + own RAMNode 4CPU + own RAMNode 5CPU + own RAMEach node works on its own part of the job, e.g. one region of a weather map.
A cluster: many ordinary computers (nodes) linked by a fast network act as one powerful system. If one node fails, the others continue.

A cluster links many computers, called nodes, with a fast network. Big jobs such as weather forecasting, film rendering or searching huge datasets are split into parts that run at the same time. Clusters can grow by adding nodes, and they keep working if one node fails. The cost is the network: sending data between nodes is far slower than inside one computer, so the job must split into parts that do not need to talk to each other often.

Uniform and non-uniform memory accessUMACPU 1CPU 2CPU 3Shared RAMsame distance for every CPUSimple and fair, but the shared bus getscrowded as more CPUs are addedNUMACPU 1Local RAMCPU 2Local RAMslowerEach CPU reaches its own RAM quickly (green),and other CPUs’ RAM more slowly (orange).Scales to many CPUs if data is kept local.
UMA: every processor has equal access to one memory. NUMA: each processor has fast local memory and slower access to the rest.

Emulation

Layers when a program runs in an emulatorOld game or appwritten for CPU family XX instructionsEmulatortranslates X → Y andimitates the old hardwareY instructionsHost computerCPU family YTranslation is extra work, so an emulated program usually runs more slowly than on real hardware.Uses: running old software on new machines, testing phone apps on a PC, preserving retro games.
Emulation makes one computer behave like another, so software written for a different instruction set can still run.
Factors affecting the choice of architecture
ArchitectureGood choice when…Watch out for…
Von Neumann with UMAa general-purpose PC or laptop with a few coresthe shared bus limiting speed
Harvarda fixed program in a small embedded controller that needs predictable speedless flexible use of memory
NUMA serverone large machine with many processors, e.g. a big databasesoftware must keep data near the processor using it
Clustera very large job that splits into independent parts, or a service that must stay upnetwork delay, cost, space, power and cooling

Key terms

Stored program
a design where the program is kept in memory and can be changed like data.
Bus
a set of parallel wires carrying addresses, data or control signals between parts.
Von Neumann bottleneck
the delay caused by instructions and data sharing one path to memory.
Node
one computer in a cluster.
NUMA
non-uniform memory access: memory near a processor is faster for it than distant memory.
Emulator
software that imitates a different computer, so its programs can run.

Think it through

Why do many microcontrollers use a Harvard architecture?

Their program is fixed in ROM/flash and never changes, and they need fast, predictable timing. Separate buses let an instruction and data be fetched at the same time.

A NUMA server runs slowly because one program’s data sits in another processor’s memory. Suggest a fix.

Have the operating system run the program on the processor next to its data, or move the data into that processor’s local memory.

Why is emulation usually slower than running on real hardware?

Every instruction written for the old processor has to be translated into instructions for the new one, which is extra work.

In the real world: weather forecasting

National weather services run their forecasts on supercomputers built as clusters of thousands of nodes. The atmosphere is divided into a 3D grid, and each node calculates its own region, exchanging only the edge values with its neighbours.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is stored in memory in a Von Neumann computer?

Open on YouTube ↗

A clear comparison of the two architectures in B1.

Watch and think:

  • Why can a Harvard processor fetch an instruction and data at the same time?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why do modern CPUs mix ideas from both architectures?

Open on YouTube ↗

Section B2 · Before the workbook

How a CPU works quickly

Your goal: Trace instruction execution and explain real performance.

Fetch, decode, execute

The CPU fetches the next instruction, decodes the operation and executes it. Execution might add numbers, move data or change the next instruction address. An instruction set defines the operations the CPU understands. A program is built from these operations.

Two instructions overlap in a three-stage pipelineCycle 1Cycle 2Cycle 3Cycle 4Instruction 1Instruction 2FetchDecodeExecuteFetchDecodeExecute
Two instructions overlap in a three-stage pipeline. Follow the labels as you read.

Overlap work with a pipeline

A pipeline lets different instructions occupy different stages at the same time. Instruction 2 may be fetched while instruction 1 is decoded. This can increase the number of completed instructions over time. It does not mean every instruction finishes instantly. A branch, a dependency or missing data can stall the pipeline.

Keep useful data nearby

Registers and cache provide fast storage close to the processor. A cache hit finds the requested data there. A miss requires a slower access elsewhere. Larger cache may help some workloads, but results depend on what the program accesses.

Measure the whole task

Clock speed measures cycles each second, not useful tasks finished. Instruction count, work per cycle, cache, memory and parallel software all affect speed. Multiprocessing uses several processing units. Multithreading provides several threads of execution. Mobile and embedded processors often prioritise low power, heat and predictable response. Desktop and server processors may prioritise throughput, capacity and reliability.

Worked example

With three stages and no stalls, instruction 1 uses cycles 1, 2 and 3. Instruction 2 uses cycles 2, 3 and 4. Two instructions finish after four cycles rather than six in this simplified model.

Pause and think

What happens if instruction 2 needs a result instruction 1 has not produced?

Check your thinking

It may need to wait. That dependency can cause a pipeline stall unless the processor has a way to handle it.

Go deeper · B2

The instruction cycle in more detail

The fetch–decode–execute cycleFETCHDECODEEXECUTEcopy the next instructionfrom memory into the CPUcontrol unit works out what it meansthe ALU calculates, data moves, or the PC jumpsrepeatsbillions oftimes a second
The instruction cycle. The clock keeps every step in time; each tick moves the cycle on.

Every program, from a game to a spreadsheet, is turned into millions of simple machine instructions such as load a number, add, compare and jump. The list of instructions a processor understands is its instruction set. A 3 GHz clock ticks three billion times a second, so one tick lasts about 0.33 nanoseconds.

Two approaches to instruction sets
RISC (reduced instruction set)CISC (complex instruction set)
Instructionsfew, simple, mostly one clock cycle eachmany, some doing several steps in one instruction
Programsneed more instructionsneed fewer instructions
Chipsimpler, uses less power and heatmore complex, traditionally more power
Typical usephones, tablets, many newer laptops (e.g. ARM)most desktop PCs and many servers (x86)

Pipelining

Instructions overlapping in a three-stage pipelineClock cycle →12345678Instruction 1FetchDecodeExecuteInstruction 2FetchDecodeExecuteInstruction 3FetchDecodeExecuteInstruction 4FetchDecodeExecuteInstruction 5FetchDecodeExecuteInstruction 6FetchDecodeExecuteWithout a pipeline: 6 instructions × 3 steps = 18 cycles. With it: 3 + (6 − 1) = 8 cycles.A branch can make the fetched instructions wrong, so they are thrown away (a pipeline flush).
Pipelining. While one instruction executes, the next is being decoded and the one after is being fetched.

Cores, threads and cache

Inside a four-core processor chipOne CPU chipCore 1L1 cacheL2 cacheCore 2L1 cacheL2 cacheCore 3L1 cacheL2 cacheCore 4L1 cacheL2 cacheShared L3 cacheMemory controller → RAM
A multi-core CPU. Each core runs its own instructions; small private caches are fastest, and a larger L3 cache is shared.

A multi-core processor has several complete processing units on one chip; multi-processing means using more than one of them at the same time. A program can be written as several threads, flows of work that the OS can run on different cores. Some cores can also run two threads at once, switching to the second thread whenever the first is waiting for memory. Cache keeps copies of recently used instructions and data close to the core: a cache hit is fast; a cache miss means a much slower trip to RAM.

CPU performance factors
FactorUnitEffect on speed
Clock speedGHzmore cycles per second, but more heat and power
Number of corescoresmore work at once, if the software uses threads
Cache sizeMBfewer slow trips to RAM
Manufacturing processnm (nanometres)smaller transistors: more of them per chip, less power, less heat
Core design / generationproduct familynewer designs do more work per clock cycle

Worked example: Why 4 cores is not 4 times faster

  1. A video export takes 12 seconds on one core. Three-quarters of the work (9 s) can be split between cores; one-quarter (3 s) must run in order.
  2. On 4 cores, the parallel part takes 9 ÷ 4 = 2.25 s, but the sequential part still takes 3 s.
  3. Total = 3 + 2.25 = 5.25 s. The speed-up is 12 ÷ 5.25 ≈ 2.3 times, not 4 times.
  4. Adding even more cores gets closer and closer to 3 s but can never beat it, because the sequential part cannot be shared.

Extra cores only speed up the part of a job that can run in parallel.

Different CPU architectures for different jobs
CPU typeDesigned forTypical features
Embeddedone fixed job inside a device (washing machine, car engine)low cost and power; often has its own memory and inputs/outputs on the chip
Mobilephones, tablets, thin laptopsbattery life first: a mix of fast and efficient cores in a SoC, slows down when hot
Microcomputer (PC)general desktop and laptop usehigh single-core speed, several cores, upgradable, fan cooling
Servermany users and requests, all daymany cores, huge caches, support for lots of RAM, error-correcting memory, reliability features

Key terms

Instruction set
all the machine instructions a processor can carry out.
Pipelining
overlapping the fetch, decode and execute stages of different instructions.
Cache hit / miss
whether the data needed was already in cache (hit) or had to come from RAM (miss).
Thread
a separate flow of instructions within a program that can run alongside others.
Clock speed
how many cycles the CPU completes each second, measured in GHz.

Think it through

Why might a phone run a demanding game more slowly after 10 minutes?

The chip heats up, so it lowers its clock speed (throttles) to protect itself and save battery.

Doubling the clock speed does not always halve the time a program takes. Why not?

The CPU may be waiting for memory, storage or the network. A faster clock does not make those parts faster.

Which would help a web server handling thousands of small requests more: a faster clock or more cores?

More cores, because each request is independent and can be handled in parallel.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What do the ALU and control unit each do?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why don’t four cores make every program four times faster?

Open on YouTube ↗

Stretch: pipelining explained by a computer scientist.

Watch and think:

  • What happens to a pipeline when the program branches?

Open on YouTube ↗

Section B3 · Before the workbook

Tiny storage inside the CPU

Your goal: Follow the roles of registers during fetch and interrupts.

Addresses and values are different

An address identifies a memory location. A value is the data stored there. The program counter (PC) holds the address of the next instruction. The memory address register (MAR) holds the location being accessed. The memory data register (MDR) holds data travelling to or from memory.

Addresses and instruction data follow different registersPC → MARaddress 204Memory → MDRinstruction dataIRcurrent instructionSimplified fetch: the PC then advances according to the architecture.
Addresses and instruction data follow different registers. Follow the labels as you read.

Follow a fetch

In a simplified fetch, the PC value is copied to MAR. The instruction at that address is read into MDR and then copied into the instruction register (IR). The PC is advanced to the next instruction address according to the architecture. The CPU decodes and executes the instruction. A branch can change the next address.

Other registers

An accumulator may hold arithmetic results. General-purpose registers hold temporary values such as operands and intermediate results. Registers are tiny and fast; they are not the same as RAM. Their exact names and use vary between processor designs.

Respond to an interrupt

A device or event can request attention through an interrupt. The CPU and OS preserve enough information about the current work, run the relevant interrupt handler, then resume when appropriate. Without correct state handling, the program could continue with the wrong values.

Worked example

If PC holds 204, MAR receives address 204. Memory returns the instruction stored there through MDR to IR. The number 204 is an address; the instruction read from that address is different information.

Pause and think

Which register holds the current instruction?

Check your thinking

The instruction register, often called IR or CIR. PC holds the next instruction address.

Go deeper · B3

Where the registers sit

Registers inside the CPU and the buses to memoryCPUPCprogram counter:next instruction addressCIRcurrent instructionregisterMARmemory addressregisterMDRmemory dataregisterACCaccumulator:results from the ALUALUControlunitMain memoryAddrHolds0LOAD 201ADD 21207215address bus (one way)data buscontrol bus
The special registers. The MAR sends addresses out; the MDR holds whatever comes back from, or goes to, memory.

Registers are the fastest storage in the whole computer because they are part of the CPU itself, but there are only a few of them. General-purpose registers hold values a program is working on, such as a loop counter. Special registers have one fixed job in the instruction cycle. A 64-bit processor has 64-bit registers, so it can move or add 8 bytes in one step.

Worked example: Tracing the registers for a tiny program

  1. Memory holds: address 0 = LOAD 20, address 1 = ADD 21, address 2 = STORE 22, address 20 = 7, address 21 = 5.
  2. Fetch 1: PC = 0 is copied to the MAR. The instruction LOAD 20 arrives in the MDR, is copied to the CIR, and the PC becomes 1.
  3. Execute 1: 20 goes to the MAR, the value 7 comes back into the MDR and is copied to the ACC. ACC = 7.
  4. Fetch 2: MAR = 1, CIR = ADD 21, PC = 2. Execute 2: MAR = 21, MDR = 5, the ALU adds 7 + 5. ACC = 12.
  5. Fetch 3: MAR = 2, CIR = STORE 22, PC = 3. Execute 3: MAR = 22, MDR = 12, and 12 is written into address 22.

The PC always moves on during the fetch, before the instruction is executed.

Trace table for the three-instruction program
StepPCMARMDRCIRACC
Fetch LOAD 200 → 10LOAD 20LOAD 20–
Execute1207LOAD 207
Fetch ADD 211 → 21ADD 21ADD 217
Execute2215ADD 2112
Fetch STORE 222 → 32STORE 22STORE 2212
Execute32212STORE 2212

Interrupts

How the CPU handles an interruptFinish the currentinstructionAny interruptwaiting?yesSave PC andregisters (stack)Run the interruptservice routineRestore registers,carry onno: fetch the next instruction as normalHigher-priority interrupts (e.g. power failing) are handled before lower ones (e.g. a key press).
Interrupt handling. The CPU checks for interrupts between instructions, so it never abandons one halfway.
Where interrupts come from
Interrupt sourceExampleWhy it is needed
Hardwarekey pressed, mouse moved, network packet arrived, disc read finisheddevices get attention only when they need it, instead of the CPU checking them constantly
Timerthe OS clock ticks every few millisecondslets the scheduler swap between programs for multitasking
Softwarea program asks the OS to open a file (a system call)programs must ask the kernel to use hardware
Errordivide by zero, or an attempt to use protected memorythe OS can stop the faulty program safely

Key terms

Program counter (PC)
holds the address of the next instruction to fetch.
MAR
holds the address of the memory location being read or written.
MDR
holds the data or instruction just read from, or about to be written to, memory.
CIR
holds the instruction currently being decoded and executed.
Accumulator
holds the result of the last calculation by the ALU.
Interrupt service routine
the code that runs to deal with a particular interrupt.

Think it through

Why must the PC and registers be saved before an interrupt is handled?

The interrupt routine will use the registers too. Saving them means the original program can carry on exactly where it stopped, as if nothing happened.

In the trace, why does the MAR hold 20 during the first execute step?

LOAD 20 needs the value stored at address 20, so that address goes to the MAR to read it from memory.

What would happen if a JUMP 0 instruction was executed?

The PC would be set to 0, so the next fetch would start the program again from the beginning.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is the difference between the MAR and the MDR?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Which bus is one-way and which is two-way?

Open on YouTube ↗

Stretch: what really happens when an interrupt arrives.

Watch and think:

  • What does the CPU save before it handles an interrupt?

Open on YouTube ↗

Section C1 · Before the workbook

Binary numbers

Your goal: Convert and calculate with binary, BCD and fixed-width values.

Bits and place values

A bit is 0 or 1. Eight bits form a byte. Binary place values double as you move left: 1, 2, 4, 8, 16, 32 and so on. Add the places that contain 1. For 00101101, the total is 32+8+4+1=45. State the bit width. Use kB=1000 bytes or KiB=1024 bytes when the question specifies it.

Decimal 45 represented in binary and BCDThe same decimal value: 45Binary0010110132 + 8 + 4 + 1BCD0100 0101digit 4 digit 5
Decimal 45 represented in binary and BCD. Follow the labels as you read.

Four arithmetic operations

Addition carries when a column reaches two: 1011+0110=10001. Subtraction borrows from the next place: 1010−0011=0111. Multiplication forms shifted partial products: 11×101=1111. Division can use repeated place-value steps: 1100÷11=100. Check each result in decimal while learning.

BCD codes each decimal digit

BCD uses four bits for each decimal digit. Decimal 45 becomes 0100 0101. In BCD addition, if a digit sum is above 9 or produces a carry, add 0110 to correct the digit. For 8+7, 1000+0111=1111; adding 0110 gives 1 0101, which becomes BCD 0001 0101. For other BCD operations, work with decimal digits and valid carries/borrows, then encode each resulting digit. For example 12−5=7 is BCD 0000 0111, not an invalid four-bit digit.

Negative values and fractions

In eight-bit two’s complement, invert the bits of +5 (00000101) and add 1 to get −5 (11111011). The range is −128 to 127. Overflow happens when a result does not fit. Floating point stores a scaled number: 6.5 can be written as 1.101₂ × 2². Real formats set the mantissa and exponent widths. Finite precision means some values round; always use the format given.

Worked example

Decimal 26 = 16+8+2, so eight-bit binary is 00011010. BCD is 0010 0110 because it encodes the digits 2 and 6 separately.

Pause and think

What is 0101 + 0011 in binary?

Check your thinking

1000. Decimal 5+3=8, which is a useful check.

Go deeper · C1

Units, and why 1,000 is not always 1,000

Units of digital data from bit to terabytebit0 or 1nibble4 bitsbyte8 bitskilobyte1,000 bytesmegabyte1,000 kBgigabyte1,000 MBterabyte1,000 GBStorage makers use powers of 10 (1 kB = 1,000 bytes). Operating systems often use powers of 2:1 KiB (kibibyte) = 1,024 bytes, 1 MiB = 1,024 KiB, 1 GiB = 1,024 MiB.That is why a “500 GB” drive shows as about 465 GiB on a computer: same bytes, different unit.
Units of data. Read the question carefully to see whether it means 1,000 or 1,024.

Hexadecimal: a short way to write binary

Converting a byte between binary, hexadecimal and denary128643216842110110110binary1011 = 8+2+1 = 11 = B0110 = 4+2 = 6Hexadecimal: B6 Denary: 128 + 32 + 16 + 4 + 2 = 182Hex digits:0–9, thenA=10 B=11 C=12D=13 E=14 F=15
Each hexadecimal digit stands for exactly one nibble (4 bits), so a byte is always two hex digits: 00 to FF.

Programmers and technicians use hexadecimal (base 16) because it is much easier to read than long binary strings but converts to binary instantly. You will see it in colour codes such as #FF8000, network MAC addresses such as 3C:22:FB:19:A0:7E, and memory addresses in error messages.

The 16 nibbles
DenaryBinaryHexDenaryBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F

Binary arithmetic

Adding two binary bytes9201011100+ 5800111010= 150100101101111Rules for each column:0 + 0 = 00 + 1 = 11 + 1 = 0, carry 11 + 1 + 1 = 1, carry 1Carries (orange) move one column to the left, just like carrying 10 in denary.
Binary addition, worked from right to left. Check it: 92 + 58 = 150.

Worked example: Subtraction by adding a negative (35 − 12)

  1. Write 12 in binary: 0000 1100.
  2. Make it negative with two’s complement: flip every bit 1111 0011, then add 1 → 1111 0100 (−12).
  3. Add 35 (0010 0011) + (−12) (1111 0100) = 1 0001 0111.
  4. Throw away the carry that falls off the left of the 8 bits: 0001 0111 = 16 + 4 + 2 + 1 = 23.

Computers subtract by adding a negative number, so the same adder circuit does both jobs.

Worked example: Multiplying and dividing with shifts

  1. Shifting left one place doubles a number: 0000 0110 (6) becomes 0000 1100 (12).
  2. To multiply 6 × 5, write 5 as 4 + 1: (6 shifted left twice) + 6 = 24 + 6 = 30, which is 0001 1110.
  3. Shifting right one place halves a whole number: 0010 1100 (44) shifted right twice is 0000 1011 (11), so 44 ÷ 4 = 11.
  4. Longer divisions use the same ‘bus stop’ method as denary, but each step only asks: does it go in once, or not at all?

Negative numbers and fractions

Eight-bit two's complement place values and range−128643216842111101100−20 =−128 + 64 + 32 + 8 + 4 = −20−1280+127negative numbers start with 1positive numbers start with 0
In two’s complement the leftmost bit is worth −128, so eight bits store −128 to +127.
A floating point number made of a mantissa and an exponentMantissa (the digits)01101000sign bit, then binary point: 0.1101000Exponent (the scale)00110011 = +3: move the point 3 right0.1101 × 2³ → 110.1 = 4 + 2 + 0.5 = 6.5More mantissa bits = more precision (accuracy). More exponent bits = bigger range of sizes.
Floating point works like scientific notation in binary. Most fractions (such as 0.1) cannot be stored exactly, so they are rounded.

Binary coded decimal (BCD) stores each denary digit in its own nibble. It is less efficient than pure binary but converts easily to the digits on a display, which is why calculators, digital clocks and some financial systems use it. When a BCD digit adds up to more than 9, add 0110 (6) to correct it and carry into the next digit.

Key terms

Nibble
four bits; one hexadecimal digit.
Hexadecimal
base 16, using 0–9 and A–F.
Two’s complement
a way to store negative whole numbers where the leftmost bit has a negative place value.
Overflow
when a result is too big for the number of bits available.
Mantissa
the part of a floating point number that holds its digits.
Exponent
the part of a floating point number that says where the binary point goes.

Think it through

Convert 0100 1111 to hexadecimal and denary.

0100 = 4 and 1111 = F, so it is 4F. In denary, 64 + 8 + 4 + 2 + 1 = 79.

What is the largest number an unsigned byte can hold, and the largest in two’s complement?

Unsigned: 255 (1111 1111). Two’s complement: +127 (0111 1111).

Why can a bank not simply store £0.10 as a floating point number?

0.1 has no exact binary form, so it would be stored as a tiny bit more or less. Over millions of transactions those rounding errors add up, so money is stored as whole pence (or in BCD/decimal types).

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

From your lessons · C1

Extra detail from your teacher’s Unit 2 lessons. Practise it on the Diagram tasks page.

Recognising a number base from its digits
BaseDigits allowedExampleUsed for
Binary (base 2)0 11011how computers store everything
Octal (base 8)0–717older systems; Linux file permissions (chmod 755)
Denary / decimal (base 10)0–9985everyday counting
Hexadecimal (base 16)0–9, A–F3Fcolour codes, MAC addresses, memory addresses

A number can only belong to a base if every digit is smaller than the base. 1,0 could be any base; 7 could be octal, denary or hex but not binary; 8 rules out octal; any letter A–F means hexadecimal.

Worked example: octal to binary and denary

  1. Each octal digit is exactly 3 bits: 7 = 111, 5 = 101.
  2. So octal 75 = 111 101 in binary.
  3. In denary: 7 × 8 + 5 = 61.

Octal 75 = binary 111101 = denary 61

Think it through

Which bases could the digits 1, 9, 8, 5 belong to?

Denary and hexadecimal only: 9 and 8 are too big for binary and octal.

Why is hex used for colour codes like #FF8800?

Each pair of hex digits is one byte (0–255) for red, green or blue, written in just two characters.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why do computers use binary?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Convert 1011 0110 to denary.

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is an overflow error?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is −1 in 8-bit two’s complement?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why is one hex digit worth exactly four bits?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What does a left shift of 2 places do to the value?

Open on YouTube ↗

Stretch: an animated explanation of floating point.

Watch and think:

  • What do the mantissa and exponent each control?

Open on YouTube ↗

BCD and where it is still used, e.g. digital displays and controllers.

Watch and think:

  • Write 59 in BCD.

Open on YouTube ↗

Section C2 · Before the workbook

Letters as numbers

Your goal: Explain character sets, code points and stored bytes.

Characters need codes

Computers store text using agreed number codes. A character set says which characters exist and how they are identified. ASCII is a limited set including Latin letters, digits and common punctuation. Seven-bit ASCII has 128 possible codes. It cannot represent every writing system.

From a character to stored bytesAcharacterU+0041code point01000001UTF-8 byteOther UTF-8 characters may use more than one byte.
From a character to stored bytes. Follow the labels as you read.

Unicode covers more languages

Unicode assigns code points to a wide range of characters. An encoding such as UTF-8 turns those code points into stored bytes. A code point is not the same thing as a byte. In UTF-8, A occupies one byte while many other characters require more. A visible symbol can sometimes involve more than one code point.

Why this matters

A school needs names to remain correct after saving, searching and transferring records. If one system expects a different encoding, text can become unreadable or lose characters. Test inputs from several languages and check round trips: type, save, reopen, export and import.

Plan storage carefully

Do not calculate byte size by counting visible letters unless the encoding and limits justify it. Field length rules may count characters or bytes differently. Use the convention stated in an exam question.

Worked example

The code point for A is U+0041. UTF-8 stores it as one byte, 01000001. UTF-8 stores é as two bytes. That difference affects byte-size calculations.

Pause and think

Does Unicode mean that every character takes two bytes?

Check your thinking

No. Unicode defines code points; the chosen encoding determines how they are stored.

Go deeper · C2

Inside the ASCII code

Upper and lower case letters differ by one bitCharacterDenaryBinaryA650100 0001a970110 00017550011 0111only this bit (worth 32)is differentMask to upper case: 0110 0001 (a) AND 1101 1111 = 0100 0001 (A)Mask to lower case: 0100 0001 (A) OR 0010 0000 = 0110 0001 (a)Digit character to number: 0011 0111 ('7') AND 0000 1111 = 0000 0111 (7)
ASCII was designed so that simple bit masks change letter case or turn a digit character into its value.

ASCII uses 7 bits, giving 128 codes: control codes (such as new line), the space, digits, punctuation and the English upper and lower case letters. Many systems use an 8-bit extended ASCII with 256 codes, but different countries filled the extra 128 codes differently, so a file could show the wrong symbols on another computer.

Unicode characters and how many UTF-8 bytes they needCharCode pointNameUTF-8 sizeBytes (hex)AU+0041Latin capital A1 byte41éU+00E9e with acute accent2 bytesC3 A9中U+4E2DChinese ‘middle’3 bytesE4 B8 AD😀U+1F600grinning face emoji4 bytesF0 9F 98 80ASCII characters keep the same single byte in UTF-8, so old English text is still valid.
Unicode gives every character a code point; UTF-8 stores common characters in 1 byte and others in 2–4 bytes.

Unicode solves this by giving one agreed number, a code point, to more than 150,000 characters from almost every writing system, plus symbols and emoji. UTF-8 is the most common way to store those code points as bytes. The first 128 Unicode code points are the same as ASCII, which made the change-over much easier.

ASCII and Unicode compared
ASCIIUnicode (UTF-8)
Characters128 (7-bit)over 150,000
Bytes per character11 to 4
LanguagesEnglish onlyalmost every language, maths symbols and emoji
Implicationssmall files, very simplenames and text from any country display correctly; some characters take more space

Key terms

Character set
the list of characters a system can represent, and the code for each one.
Code point
the unique number Unicode gives to a character, written like U+0041.
UTF-8
a variable-length encoding that stores Unicode code points in 1–4 bytes.
Bit mask
a pattern used with AND, OR or XOR to change or test chosen bits.

Think it through

The ASCII code for ‘D’ is 68. What is the code for ‘d’?

Lower case letters are 32 more than upper case: 68 + 32 = 100.

A website shows ‘café’ instead of ‘café’. What has gone wrong?

The text was saved as UTF-8 (é is two bytes) but read as an older 1-byte character set, so each of the two bytes appears as a separate wrong symbol.

How many bytes does the word ‘naïve’ take in UTF-8?

Five characters: n, a, v and e take 1 byte each and ï takes 2, so 6 bytes.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why did Unicode replace ASCII for most uses?

Open on YouTube ↗

Section C3 · Before the workbook

Pictures made from pixels

Your goal: Calculate raw image size and choose suitable compression.

A raster image is a grid

A bitmap or raster picture is made of pixels. Width and height give the grid size. More pixels can show finer detail if the original image contains it. Enlarging a small image does not automatically create real detail.

Pixels form a raster imageWidth × height × bit depth= raw pixel-data bitsDivide by 8 for bytesHeaders and compression change file size.
Pixels form a raster image. Follow the labels as you read.

Bit depth describes each pixel

Bit depth is the number of bits used per pixel in the stated format. A simple 8-bit value has 256 possible patterns. A common 24-bit colour image allocates 8 bits each to red, green and blue. Resolution and bit depth affect both quality and storage.

Calculate in clear steps

Raw pixel-data bits = width × height × bit depth. Divide by 8 for bytes. This excludes headers, metadata, padding and compression. A real saved file can therefore have a different size.

Keep the right versions

Lossless compression allows exact reconstruction. Lossy compression removes some information to save space and may cause visible artefacts. A photographer may keep a high-quality master for editing and printing, plus smaller web copies for faster loading. A vector drawing stores shapes rather than a fixed pixel grid; it can be useful for scalable diagrams, although C3 focuses on raster data.

Worked example

A 200×100 image at 8 bits per pixel uses 20,000 pixels ×8 =160,000 bits. Divide by 8 to get 20,000 bytes of raw pixel data.

Pause and think

If both width and height double at the same bit depth, what happens to raw size?

Check your thinking

It becomes four times as large: there are twice as many rows and twice as many columns.

Go deeper · C3

From pixels to bits

A tiny black and white image stored as bits8 × 8 pixels, 1 bit each0011110001000010101001011000000110100101100110010100001000111100stored row by row1-bit depth: 2 colours8-bit: 256 colours24-bit: about 16.7 millionA 24-bit pixel is 3 bytes:Red255Green128Blue0= orange, hex #FF8000
A bitmap is a grid of pixels. Each pixel is stored as a number; the bit depth decides how many colours that number can describe.
The same circle at low and high resolution8 × 8 = 64 pixels16 × 16 = 256 pixels40 × 40 = 1,600 pixels
Higher resolution means more, smaller pixels: smoother edges and more detail, but a bigger file.

Worked example: How big is an uncompressed photo?

  1. A photo is 1,200 × 800 pixels with 24-bit colour.
  2. Number of pixels = 1,200 × 800 = 960,000.
  3. Bits = 960,000 × 24 = 23,040,000 bits.
  4. Bytes = 23,040,000 ÷ 8 = 2,880,000 bytes ≈ 2.88 MB (using 1 MB = 1,000,000 bytes).
  5. The real file is a little bigger, because a header stores the width, height and bit depth, plus metadata such as the date and camera.

File size = width × height × bit depth ÷ 8 bytes.

Enlarging a vector image and a bitmap imageVector: stores shapescircle: centre (70,55)radius 40, fill blueRedrawn from the formula at any size: always sharpBitmap: stores pixelsEnlarged pixels show jagged ‘stair steps’Vectors suit logos, diagrams and fonts; bitmaps suit photographs.
Vector graphics store instructions for shapes; bitmaps store every pixel.

Compression

Run-length encoding of one row of pixelsStored pixel by pixel: 16 valuesRun-length encoded: 5 white, 3 black, 8 white → 3 pairsLossless: the row can be rebuilt exactly. Works best on large areas of one colour.
Run-length encoding (RLE) is a simple lossless compression method.
Common image formats
FormatCompressionBest for
JPEGlossy: removes detail the eye notices leastphotographs on web pages and phones
PNGlosslessscreenshots, logos and images with sharp edges or transparency
GIFlossless, but only 256 colourssimple animations and icons
RAW / TIFFnone or losslessoriginal photos that will be edited or printed
SVGvector (not pixels)logos, diagrams and icons that must scale

Screens make colours by adding red, green and blue light (RGB). Printers work the other way, mixing cyan, magenta, yellow and black ink (CMYK) that absorbs light. Images for print are therefore often converted, and a colour that looks bright on screen may print duller.

Key terms

Pixel
the smallest dot of colour in a bitmap image.
Resolution
the number of pixels in an image, given as width × height.
Bit depth (colour depth)
the number of bits used for each pixel; n bits give 2ⁿ colours.
Metadata
data about the image, such as its size, date and camera settings.
Lossless
compression that can rebuild the original exactly.
Lossy
compression that permanently removes some data to make a much smaller file.

Think it through

How many colours can a 4-bit image show?

2⁴ = 16 colours.

Why does a logo look blurry when a small JPEG of it is enlarged on a poster?

The JPEG is a bitmap with a fixed number of pixels. Enlarging it makes each pixel bigger, and JPEG compression has already removed sharp-edge detail. A vector (SVG) logo would stay sharp.

An image doubles its resolution in both directions. What happens to the uncompressed file size?

It becomes four times bigger, because there are twice as many pixels across and twice as many down.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • How does colour depth affect file size?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • How do sample rate and bit depth affect quality?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • When must you use lossless compression?

Open on YouTube ↗

Section D1 · Before the workbook

Stacks, queues, arrays and lists

Your goal: Trace data structures and justify their use.

A stack reverses arrival order

A stack is last-in first-out (LIFO). Push adds to the top; pop removes from the top. A pile of trays is a useful analogy. Programs use call stacks to return from nested function calls. A full stack may overflow; trying to remove from an empty one is also an error to handle.

Stack and queue remove different itemsStack: last in, first outCtop — leaves firstBA is below BQueue: first in, first outAfrontBCrearA arrived first and leaves first.
Stack and queue remove different items. Follow the labels as you read.

A queue keeps arrival order

A queue is first-in first-out (FIFO). Enqueue adds at the rear; dequeue removes from the front. Print jobs and hardware buffers often use queue behaviour. Real scheduling can add priorities, but that is an extra rule rather than ordinary FIFO.

Arrays and lists organise sequences

An array uses numbered positions, called indices. Many languages start with index 0. Arrays are useful when you need direct access by position. A list is an ordered collection; the costs of access, adding and removing depend on how the list is implemented. Do not assume all lists work the same way.

Choose by the required operations

Ask what arrives, which item must leave next, whether you need direct access and what happens when capacity is reached. The same idea may appear in software and hardware: a printer queue is managed in software, while a device buffer may also behave as a queue.

Worked example

Push A, push B, pop, push C leaves a stack with C at the top and A below. Enqueue A, enqueue B, dequeue, enqueue C leaves B at the front and C at the rear.

Pause and think

Why does FIFO suit ordinary print jobs?

Check your thinking

It keeps the order in which jobs were accepted, unless a separate priority rule changes that order.

Go deeper · D1

Seeing the structures

A stack and a queue side by sideStack (LIFO)DCBA← toppushpopLast in, first out: D comes off firstQueue (FIFO)ABCDfrontreardequeueenqueueFirst in, first out: A leaves first
A stack adds and removes at the same end (the top). A queue adds at the rear and removes from the front.

Stacks and queues are defined by where items can be added and removed, not by how they are stored. Both can be built inside an array, using a variable (a pointer) to remember where the top, front or rear is. In a circular queue the rear wraps round to the start of the array when it reaches the end, so the free spaces at the front can be reused.

Inserting an item into a linked list by changing pointersAli•Ben•Dev•ZoenullCal•1. Ben now points to Cal2. Cal points to DevNo items move in memory: only two pointers change. An array would have to shift Dev and Zoe along.
A linked list stores each item with a pointer to the next. Inserting ‘Cal’ in order only changes two pointers.
A binary search tree of namesMayaDevSamAliFinRaviZoeearlier in the alphabet: go leftlater in the alphabet: go rightTo find ‘Ravi’: Maya → right to Sam → left to Ravi. 3 checks instead of up to 7.
A binary tree is a list where each item has a left and a right pointer. Searching halves the remaining items at each step.
Where the data structures are used
StructureIn softwareIn hardware
Stackundo in an editor; the browser Back button; the call stack that remembers where each function should returnthe CPU’s stack pointer register; saving registers when an interrupt arrives
Queueprint jobs; messages waiting to be processed; players waiting to join a gamethe keyboard buffer; packets waiting in a router; tasks waiting for the CPU
Arraya list of scores; the pixels of an image; a game boardmemory itself is one huge array of numbered locations
Lista music playlist; a to-do list that changes often; a sorted list of namesblocks of a file on a disc chained together

Data types

Common data types
Data typeHoldsExampleTypical size
Integerwhole numbersage = 152–8 bytes
Real / floatnumbers with a fractional partprice = 4.994 or 8 bytes
Characterone charactergrade = 'B'1–4 bytes
Stringa sequence of charactersname = 'Priya'1+ byte per character
Booleantrue or falsepaid = true1 bit (often stored in a byte)
Date/timea moment in time2026-09-28 14:05usually 8 bytes

Choosing the right type matters: storing a phone number as an integer would lose the leading zero and allow nonsense such as adding two phone numbers together, so it should be a string. Storing money as a float can create rounding errors, so money is often held as a whole number of pence.

Worked example: Undo with a stack

  1. A student types ‘cat’, then makes it bold, then changes the colour. Each action is pushed onto the undo stack: [type, bold, colour] with ‘colour’ on top.
  2. Pressing Undo pops ‘colour’ and reverses it. Pressing Undo again pops ‘bold’.
  3. The most recent action is always undone first, which is exactly the last-in, first-out behaviour of a stack.

Key terms

Pointer
a value that holds the position (address or index) of another item.
LIFO / FIFO
last in, first out (stack) / first in, first out (queue).
Linked list
a list where each item stores a pointer to the next item.
Binary tree
a structure where each item points to up to two others, left and right.
Index
the position number of an item in an array, usually starting at 0.

Think it through

Why is a queue used for print jobs rather than a stack?

It is fair: documents print in the order they were sent. With a stack, the newest job would print first and early jobs could wait forever.

Why is finding an item in a linked list slower than in an array?

An array can jump straight to position n using the index. A linked list must follow the pointers one by one from the start.

What data type should a postcode be, and why?

A string, because it mixes letters, digits and a space, and no calculations are done with it.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is the difference between an array and a record?

Open on YouTube ↗

Stacks (last in, first out) and queues (first in, first out) explained.

Watch and think:

  • Give a real use of a stack and a queue.

Open on YouTube ↗

Section D2 · Before the workbook

Grids, arrays and matrices

Your goal: Use array indices, storage order and matrix operations.

Rows, columns and dimensions

A one-dimensional array is a sequence. A two-dimensional array is a grid. Three or more dimensions can represent extra categories, such as room, day and lesson. A matrix is a rectangular grid of numbers. A two-dimensional array can store a matrix, but an array can also hold other kinds of data.

Row-major offsets with zero-based indexing3 rows × 4 columns01234567891011Cell [2,1]Row-major: 2 × 4 + 1 = 9Column-major: 1 × 3 + 2 = 5The values in this grid are row-major offsets.
Row-major offsets with zero-based indexing. Follow the labels as you read.

Store a grid in a line

Memory is addressed as a sequence. Row-major order stores one complete row before the next. Column-major order stores one complete column before the next. For a zero-based R×C grid, row-major offset = r×C+c. Column-major offset = c×R+r. To get a byte address, multiply the element offset by bytes per element, then add the base address.

Add and multiply matrices

To add matrices, add matching positions; their dimensions must match. Matrix multiplication takes a row from the first matrix and a column from the second, multiplies matching values and adds the products. The first matrix’s column count must match the second matrix’s row count. Swapping the order can change the result.

Transpose, transform and inverse

A transpose swaps rows and columns. Matrices can transform coordinates, such as doubling x and y. For a 2×2 matrix [[a,b],[c,d]], an inverse exists only when ad−bc is not zero. An inverse reverses the transformation; it is not generally the transpose.

Worked example

For [[1,2],[3,4]] × [[2,0],[1,2]], the top-left value is 1×2+2×1=4. The full result is [[4,4],[10,8]]. In a zero-based 3×4 array, [2,1] has row-major offset 9 and column-major offset 5.

Pause and think

What is the row-major offset of [1,2] in a zero-based 3×4 grid?

Check your thinking

1×4+2=6. Offset 0 is the first element.

Go deeper · D2

Arrays of any size

One, two and three dimensional arrays1D: scores[4]1291571101234one index2D: seats[row][col]two indexes: seats[2][3]3D: pixels[layer][row][col]three indexes, e.g. R, G and B layers
An array can have any number of dimensions. A matrix is a 2D array of numbers you can calculate with.
Row-major and column-major order in memoryThe grid (2 rows × 3 columns)abcdefRow-major: rows one after anotherabcdef012345Column-major: columns one after anotheradbecf012345Where is ‘f’ (row 1, col 2)?row-major: 1 × 3 + 2 = 5col-major: 2 × 2 + 1 = 5‘b’ is 1 in row-major but 2 in column-major
Memory is one long line, so a grid must be flattened. Languages choose row-major or column-major order.

A program can calculate where any item is stored without searching. For a grid with R rows and C columns stored in row-major order, item [row][col] is at offset row × C + col. In column-major order it is at col × R + row. Multiplying the offset by the size of each item gives the byte position. Reading memory in the order it is stored is faster, because nearby items arrive in cache together.

Calculating with matrices

Multiplying two matrices, row by columnA1234×B5678=19224350Top-left:row 1 of A × column 1 of B= 1×5 + 2×7 = 19Each answer = one row of the first matrix × one column of the second, multiplied in pairs and added.
Matrix multiplication. The number of columns in A must equal the number of rows in B.
Matrix operations
OperationRuleUsed for
Additionadd the matching positions (same size matrices only)combining totals, e.g. two shops’ monthly sales
Scalar multiplicationmultiply every item by one numbera 10% price rise (× 1.1)
Multiplicationrow × column, multiplied in pairs and addedrevenue from quantities × prices; transforming graphics
Transposeswap rows and columnsmaking the sizes match before multiplying
Inversethe matrix that ‘undoes’ another; exists only if the determinant is not 0solving simultaneous equations
Reflecting a triangle in the y-axis with a matrixxyoriginal (1,1) (4,1) (1,3)image (−1,1) (−4,1) (−1,3)[ −1 0 ] × [ x ][ 0 1 ] [ y ]x becomes −x; y stays
Graphics software moves, reflects, rotates and scales shapes by multiplying each corner’s coordinates by a matrix.

Worked example: Solving simultaneous equations with a matrix

  1. Cinema tickets: 2 adults and 1 child cost £11; 1 adult and 3 children cost £13. Let a = adult price, c = child price.
  2. Write it as a matrix equation: [2 1 / 1 3] × [a / c] = [11 / 13].
  3. The determinant is 2 × 3 − 1 × 1 = 5, which is not 0, so an inverse exists: (1/5) × [3 −1 / −1 2].
  4. Multiply: a = (3 × 11 − 1 × 13) ÷ 5 = 20 ÷ 5 = 4, and c = (−1 × 11 + 2 × 13) ÷ 5 = 15 ÷ 5 = 3.
  5. Check: 2 × 4 + 3 = 11 ✓ and 4 + 3 × 3 = 13 ✓. An adult ticket is £4 and a child ticket is £3.

Spreadsheets do this with array formulas such as MINVERSE and MMULT.

Key terms

Matrix
a rectangular grid of numbers arranged in rows and columns.
Dimensions
the size of a matrix, rows × columns, e.g. 2 × 3.
Row-major order
storing a grid one row after another.
Column-major order
storing a grid one column after another.
Determinant
a number calculated from a square matrix; if it is 0 there is no inverse.

Think it through

A 4 × 10 grid is stored in row-major order. What is the offset of [3][7]?

3 × 10 + 7 = 37.

Can a 2 × 3 matrix be multiplied by another 2 × 3 matrix?

No. The first has 3 columns but the second has 2 rows; they must match. Transposing the second (to 3 × 2) would make it possible.

Which matrix reflects a shape in the x-axis?

[1 0 / 0 −1]: x stays the same and y becomes −y.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

Step-by-step matrix multiplication for D2.

Watch and think:

  • Why must the columns of the first matrix equal the rows of the second?

Open on YouTube ↗

Stretch: what matrix multiplication means geometrically.

Watch and think:

  • How can a matrix move or rotate a shape?

Open on YouTube ↗

Section E1 · Before the workbook

Sending data between computers

Your goal: Describe how data travels and how it can be protected.

Describe the channel

Simplex sends one way. Half-duplex allows both ways but takes turns. Full-duplex permits both directions together. Point-to-point joins two endpoints; multi-drop shares a channel among several. Serial sends bits one after another; parallel uses several lines. Connection choices depend on distance, interference, speed, cost and mobility.

A simplified packet has different fieldsIllustrative packet — fields vary by protocolSourcewhere fromDestinationwhere toSequencepositionPayloadactual dataCheck valuedetect errorsA packet label does not provide confidentiality.
A simplified packet has different fields. Follow the labels as you read.

Timing and packets

Synchronous transmission coordinates timing; asynchronous transmission uses framing rather than a continuously shared clock. Packet switching divides a message into pieces. Packet information can include source, destination, sequence, payload and error-checking data. Exact fields depend on the protocol. Protocols are agreed rules for format and behaviour. A receiver may need to reorder packets and deal with missing ones.

Encryption and keys

A Caesar cipher uses a fixed alphabet shift; Vigenère uses changing shifts from a key. They teach the idea of encryption but should not protect modern sensitive records. Symmetric encryption uses a shared secret. Public-key methods use a related public/private key pair and can help establish keys or prove identity. Secure use also depends on key management, trusted endpoints and suitable protocols.

Compression is a different job

Compression reduces data size. Lossless compression preserves all the original information; lossy compression removes some. It does not make data confidential. A system may compress data and then encrypt it. Choose based on bandwidth and the cost of losing detail.

Worked example

Packets numbered 1, 3, 2 can be put back into order. A sequence number helps order them, but does not keep their contents secret. Encryption has that different role.

Pause and think

Why might a live video call and a medical image use different compression choices?

Check your thinking

Live video may trade some detail for smooth delivery. A diagnostic image may need exact detail, so losing information could be unacceptable.

Go deeper · E1

Channels and connections

Simplex, half-duplex, full-duplex, point-to-point and multi-dropSimplexABone way onlye.g. TV broadcast, GPSHalf-duplexABboth ways, one at a timee.g. walkie-talkieFull-duplexABboth ways at oncee.g. phone call, EthernetPoint-to-pointABMulti-drop: one shared lineCS1S2S3
Channel types describe the direction of travel and how many devices share one link.
Serial and parallel transmission of one byteParallel: 8 wires, all bits at once01000001Over distance the bits drift apart (skew)Serial: 1 wire, bits one after another01000001direction of travelFewer wires, cheaper, and fast over long cables
Parallel sends each bit on its own wire; serial sends the bits in sequence on one wire. USB, SATA and Ethernet are all serial.
Asynchronous framing and synchronous transmissionAsynchronousstart 001000001stop 1each character is wrapped in a start bit and a stop bit, so no shared clock is neededSynchronousa clock signal keeps sender and receiver in step, so long blocks are sent with no gaps
Asynchronous suits occasional data such as key presses; synchronous suits continuous, high-speed streams.
Selecting a connection method
ConnectionWired or wirelessTypical speed and rangeGood for
Ethernet (copper)wiredup to 1–10 Gbit/s, about 100 mdesktop PCs, servers, reliable office networks
Fibre opticwired (light)10+ Gbit/s over many kmlinks between buildings, internet backbones
USBwiredhundreds of Mbit/s to tens of Gbit/s, a few metresperipherals, storage, charging
Wi-Fiwireless (radio)hundreds of Mbit/s, tens of metreslaptops, phones and tablets moving around a building
Bluetoothwireless (radio)a few Mbit/s, about 10 mheadphones, keyboards, watches
4G / 5Gwireless (mobile network)tens to hundreds of Mbit/s, kilometresphones and devices on the move
NFCwireless (radio)slow, a few centimetrescontactless payment, door passes

Packets, frames and protocols

The parts of an Ethernet framePreamble7 BSFD1 BDestinationMAC6 BSourceMAC6 BType /length2 BData (payload + padding)46–1500 BFCS(CRC)4 Bheader (who, from where, what kind) · payload (the data) · trailer (error check)
A frame is a packet on a local network. The preamble lets the receiver lock on; the FCS lets it detect damage.
Packets taking different routes across a networkSendersplits into 1 2 3Receiverreorders 1 2 3R1R2R3R4R5packets 1 and 3packet 2 (a quieter route)
Packet switching. Each router sends each packet on the best route at that moment; the receiver uses sequence numbers to rebuild the message.
The TCP/IP protocol stack
TCP/IP layerJobExample protocols
Applicationthe service the user wantsHTTP/HTTPS (web), SMTP/IMAP (email), DNS (names to addresses)
Transportsplits data into segments, numbers them, checks they all arriveTCP (reliable), UDP (fast, no resending)
Internetaddresses packets and routes them between networksIP
Linkmoves frames across one physical networkEthernet, Wi-Fi

A protocol is a set of rules both sides agree to follow: the speed, the packet size and format, how the connection starts (a handshake), how errors are detected and corrected, and whether data is compressed or encrypted. Without shared protocols, devices from different makers could not understand each other.

Keeping data private: encryption

A Caesar cipher with a shift of 3ADBECFDGEHFIGJHKILJMKNLOMPNQORPSQTRUSVTWUXVYWZXAYBZCHELLO → KHOOR. Only 25 possible shifts, so a computer can try them all instantly (brute force).
A Caesar cipher replaces each letter with the one 3 places later. It is easy to understand but far too weak for real use.
Public key encryption between a browser and a shopYour browserShop’s serverShop’s PUBLIC keyshared with anyonesession key, locked with the public keyShop’s PRIVATE keynever leavesthe serverOnly the private key can unlock it. Both sides then use the fast symmetric session key.
Public (asymmetric) key encryption solves the problem of sharing a secret key over an open network.
Two kinds of encryption
SymmetricPublic key (asymmetric)
Keysone secret key, used to lock and unlocka public key to lock and a private key to unlock
Speedfastmuch slower
Problemhow to share the secret key safelyslow for large amounts of data
Used forencrypting files, discs and the main part of a secure sessionsetting up a secure connection and digital signatures

Key terms

Protocol
an agreed set of rules for communication.
Frame / packet
a unit of data with a header, a payload and usually an error check.
MAC address
a hardware address that identifies a network interface on a local network.
Packet switching
sending packets independently, possibly by different routes, then reassembling them.
Handshake
an exchange of signals to set up a connection and agree its rules before data is sent.
Cipher
a method of encrypting data; ciphertext is the encrypted result.

Think it through

Why does a video call use UDP rather than TCP?

Speed matters more than perfection. Waiting for a lost packet to be re-sent would freeze the call, so it is better to skip it and carry on.

Decrypt ‘FDW’ with a Caesar shift of 3.

Move each letter back 3 places: F→C, D→A, W→T, so the word is CAT.

Why does a secure website use both public key and symmetric encryption?

Public key encryption safely shares a session key without it being intercepted; symmetric encryption is then used for the rest because it is much faster.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

From your lessons · E1

Extra detail from your teacher’s Unit 2 lessons. Practise it on the Diagram tasks page.

The Vigenère cipher

Vigenère cipher worked examplePlaintextHELLOKey (repeated)KEYKEShift10424104CiphertextRIJVSEach letter shifts by theposition of the key letter(A = 0, B = 1 … Z = 25).The two Ls become J and V:same letter, different code.
Unlike a Caesar cipher, the shift changes with every letter, so letter-frequency analysis is much harder.

To decrypt, subtract the key shifts instead of adding them. The longer and more random the key, the harder it is to break; a key as long as the message that is never reused is called a one-time pad.

Voice over IP (VoIP)

How a VoIP call works
StepWhat happens
1 Digitisethe caller’s voice is sampled and converted to digital data
2 Compressa codec compresses the audio to reduce bandwidth (quality may drop slightly)
3 Packetisethe data is split into packets with headers and sent across the internet
4 Reassemblethe receiver puts packets in order and the codec turns them back into sound
VoIP for organisations
BenefitsDrawbacks
cheap or free calls, even internationally; use any internet-connected device; video and messaging in one appneeds a reliable connection; latency, jitter and packet loss cause echo or gaps; no service in a power or internet cut; calls can be intercepted unless encrypted

Key terms

Vigenère cipher
a substitution cipher using a keyword so each letter has a different shift.
Codec
hardware or software that compresses and decompresses audio or video.
Jitter
variation in the delay between packets, causing choppy sound.
VoIP
voice over internet protocol: phone calls sent as data packets.

Think it through

Encrypt CAT with the key BB.

Shift each letter by 1 (B = 1): C→D, A→B, T→U, giving DBU.

Why does VoIP use UDP-style delivery instead of re-sending lost packets?

A re-sent packet would arrive too late to be useful in a live conversation, so a small gap is better than a delay.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why is serial used for long distances?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What are start and stop bits for?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why are protocols organised into layers?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What is the difference between plaintext and ciphertext?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why is a public key safe to share?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Why is a Caesar cipher easy to break?

Open on YouTube ↗

The Vigenère cipher from your encryption lesson, worked through.

Watch and think:

  • Why is Vigenère harder to break than Caesar?

Open on YouTube ↗

Section E2 · Before the workbook

Spotting errors

Your goal: Explain what error checks can and cannot detect.

What can go wrong?

Noise or faults can change transmitted bits. Error detection adds information that lets the receiver check whether data is likely to have changed. Detection does not always locate the changed bit or repair it.

Even parity counts the number of onesEven parity example1 0 1 1 0 0 10parity bitFour 1s in the payload4 + 0 stays even. Two changed bits may go unnoticed.
Even parity counts the number of ones. Follow the labels as you read.

Parity counts ones

With even parity, the total number of 1 bits, including the parity bit, must be even. The payload 1011001 has four ones, so add parity bit 0. One changed bit makes the count odd. Two changed bits can leave it even, so basic parity misses some error patterns.

Other checks

A checksum is a value calculated from the data and compared at the receiver. A CRC uses a polynomial-based calculation to produce a remainder and is effective against many common transmission errors. Repetition sends data again so copies can be compared. All require extra data or work, and no simple check should be described as detecting every possible error.

Respond to the result

If the check fails, the receiver needs a correction or recovery method. Depending on the system, it might request another copy or use extra information to repair the data. That is the next step, covered in E3.

Worked example

Payload 1010110 has four ones, so even parity is 0. Flip its first bit to get 0010110: now there are three ones and the check fails. Flip its second bit too to get 0110110: there are four ones and basic parity does not notice the two changes.

Pause and think

Is a checksum the same as encryption?

Check your thinking

No. A checksum helps detect change; encryption is used to protect confidentiality. They solve different problems.

Go deeper · E2

Why errors happen

How interference changes a transmitted signalSent01101001Received01101001noise flipped a bit
Electrical interference, weak signals (attenuation) and crosstalk between wires can turn a 0 into a 1 or a 1 into a 0.

Errors are more likely over long cables, weak wireless signals, near electrical machinery, or when many wires run side by side. Error detection adds a little extra data calculated from the message. The receiver repeats the calculation: if its answer is different, something changed on the way.

Worked example: Even parity, and where it fails

  1. Send the 7-bit code 1100101. It has four 1s, already even, so the parity bit is 0: 0110 0101.
  2. One bit flips to give 0110 0111: now there are five 1s, odd, so the receiver knows it is wrong.
  3. Two bits flip to give 0110 1001: four 1s, still even, so the error is not detected.
  4. Parity also cannot say which bit is wrong, so the byte must be sent again.

Worked example: A simple checksum

  1. Four bytes are sent: 45, 120, 200 and 16.
  2. Add them: 45 + 120 + 200 + 16 = 381.
  3. Keep only what fits in one byte: 381 − 256 = 125. The checksum 125 is sent after the data.
  4. The receiver adds the four bytes it received. If it also gets 125 the data is accepted; if not, it asks for it again.
  5. Weakness: if two bytes were swapped, the total would be the same and the error would be missed.
Adding and checking a CRCData bitsCRCSender divides the data by an agreed binary number(the generator) and appends the remainderReceiver divides data + CRC againremainder 0 → acceptanything else → error detectedCRC catches all single-bit errors and almost all bursts of errors, which is why Ethernet, Wi-Fi, ZIP files and discs use it.
A cyclic redundancy check (CRC) is a more powerful checksum based on binary division.
Error detection methods compared
MethodHow it worksDetectsExtra data
Parity bitone bit makes the number of 1s even (or odd)any odd number of flipped bits1 bit per byte
Checksumsum of the data, trimmed to a fixed sizemost random errors, but not reordered data1–4 bytes per block
CRCremainder of a binary divisionalmost all errors, including bursts2–4 bytes per block
Repetitionsend everything two or three times and comparedifferences between the copiesdoubles or triples the data

Key terms

Attenuation
a signal getting weaker as it travels further.
Crosstalk
a signal in one wire interfering with a neighbouring wire.
Parity bit
an extra bit that makes the total number of 1s even or odd.
Checksum
a value calculated from a block of data and sent with it.
CRC
cyclic redundancy check: a checksum based on binary division.

Think it through

Using odd parity, what parity bit goes with 1100110?

It has four 1s (even), so the parity bit is 1 to make five, an odd number.

Why is a CRC better than a parity bit for a 1,500-byte packet?

A parity bit only catches an odd number of flipped bits. Noise often damages several bits in a row (a burst); a CRC detects almost all bursts.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Which errors can a single parity bit not detect?

Open on YouTube ↗

Stretch: how CRCs catch errors.

Watch and think:

  • Why is a CRC better than a parity bit?

Open on YouTube ↗

Section E3 · Before the workbook

Fixing errors

Your goal: Choose a correction method using delay and bandwidth.

Ask for another copy with ARQ

Automatic repeat request (ARQ) uses checks, acknowledgements and retransmission rules. If data is damaged or an acknowledgement does not arrive in time, a sender can resend. Sequence information helps avoid confusing repeated packets with new ones. ARQ needs a suitable return path and adds delay when retries occur.

ARQ asks again while FEC sends correction informationARQSenderReceiverError → request another copyFECSenderReceiverExtra data → repair some errorsChoose using delay, bandwidth and likely errors.
ARQ asks again while FEC sends correction information. Follow the labels as you read.

Repair using extra data with FEC

Forward error correction (FEC) sends redundancy that allows the receiver to correct some errors. Exactly how many errors it can repair depends on the code. The receiver may not need to wait for another transmission. The extra data uses bandwidth, and decoding takes work.

Choose for the situation

A file download can often wait for a retry because an exact final file matters. A live feed over a long-delay link may benefit from FEC. The choice depends on delay, error rate, bandwidth and the importance of exact data. Some systems combine both approaches.

Avoid a common mix-up

Detection tells the system that data may be wrong. Correction or retransmission provides a way to obtain the right data. A parity check alone is not the same as a full FEC code.

Worked example

If a damaged packet needs a 600 ms round trip before a replacement arrives, a live display may show a gap. FEC might repair a small error sooner, at the cost of sending extra bits in every protected block.

Pause and think

When errors are rare and waiting is acceptable, why might ARQ be suitable?

Check your thinking

Most data arrives without extra retries, and the receiver can ask again when needed. The return delay is acceptable for that task.

Go deeper · E3

Asking again: ARQ

Automatic repeat request timelineSenderReceiverpacket 1ACK 1 (received OK)✗ corruptedpacket 2timer runs out:no ACKpacket 2 sent againACK 2
ARQ. The receiver acknowledges good packets; if no acknowledgement arrives in time, the sender sends the packet again.

Automatic repeat request needs error detection (such as a CRC), acknowledgements (ACKs) and a timer. It sends as little extra data as possible, but each error costs a round trip. That is fine on a fast local network, but painful on a satellite link where each round trip takes over half a second.

Fixing it at the receiver: FEC

Forward error correction by sending each bit three timesDataSent (×3)ReceivedMajority vote1111111100000100111110112 bits damagedall fixed
A simple FEC code. The receiver repairs each bit by majority vote without asking for anything again, at the cost of sending three times as much.

Real systems use cleverer forward error correction codes than simple repetition. A Hamming code mixes a few parity bits into the data so that the pattern of failed parity checks points to the exact bit that flipped, which can then be flipped back. The same idea lets RAID rebuild a lost disc, lets a scratched CD still play, and lets a QR code be read even when part of it is covered.

Choosing an error correction method
ARQFEC
Needs a return channel?yes, for ACKs and requestsno
Extra data sentlittle, except when errors happenalways some extra redundancy
Delayeach error costs a round tripno waiting
Best whenerrors are rare and replies are quick (web pages, file downloads)replies are slow or impossible (space probes, live broadcasts, satellite links, storage media)

Key terms

ACK / NAK
acknowledgement (received correctly) / negative acknowledgement (please resend).
Timeout
the time a sender waits for an ACK before sending again.
Redundancy
extra data added so errors can be detected or corrected.
Hamming code
an FEC code that uses several parity bits to locate and fix a single wrong bit.

Think it through

Why is FEC used for live TV broadcasts?

A broadcast is one-way (simplex), so viewers’ TVs cannot ask for anything to be sent again. The TV must fix errors itself.

A download over a very noisy link keeps timing out. What is happening?

Many packets are damaged, so the sender keeps waiting for ACKs and re-sending. Adding some FEC, or fixing the cause of the noise, would reduce the repeats.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

How forward error correction repairs data.

Watch and think:

  • How can a receiver fix an error without asking again?

Open on YouTube ↗

Stretch: a beautiful explanation of error-correcting codes.

Watch and think:

  • What extra information lets Hamming codes locate the wrong bit?

Open on YouTube ↗

Section F1 · Before the workbook

True and false decisions

Your goal: Build truth tables and connect logic gates.

Four useful operations

AND gives 1 only when both inputs are 1. OR gives 1 when at least one input is 1. NOT reverses a value. XOR gives 1 when two inputs differ. In some notation, a dot means AND and a plus means OR. Confirm the notation and follow brackets.

Truth table for A AND NOT BA AND NOT BABNOT BOutput0010010010111100
Truth table for A AND NOT B. Follow the labels as you read.

Test every input combination

Two inputs have four combinations: 00, 01, 10, 11. Three inputs have eight. Add an intermediate column for each part of a longer expression. This makes errors easier to spot. For A AND NOT B, first find NOT B, then apply AND with A.

Build a circuit from an expression

For (A AND B) OR (B AND C), make two AND results and feed them into OR. B connects to both AND operations. The output is 1 for 011, 110 and 111 in A,B,C order. A wire crossing is not necessarily a connection, so show connections clearly.

Add bits with logic

A half adder adds two bits: sum = A XOR B and carry = A AND B. A full adder also accepts carry-in. Its sum is A XOR B XOR Cin. Carry-out is (A AND B) OR (Cin AND (A XOR B)). Trace all eight input combinations to check it.

Worked example

For A=1 and B=0, NOT B=1, so A AND NOT B=1. For A=1 and B=1, NOT B=0, so the result is 0.

Pause and think

What are the half-adder sum and carry for 1+1?

Check your thinking

Sum 0, carry 1. Together they represent binary 10, which is decimal 2.

Go deeper · F1

Every gate at a glance

The six logic gates with their symbols, notation and truth tablesANDQ = A.B1 only if both are 1A B → Q00:0 01:0 10:0 11:1ORQ = A + B1 if either is 1A B → Q00:0 01:1 10:1 11:1NOTQ = Āreverses the inputA → Q: 0:1 1:0NANDQ = NOT(A.B)AND, then NOTA B → Q00:1 01:1 10:1 11:0NORQ = NOT(A + B)OR, then NOTA B → Q00:1 01:0 10:0 11:0XORQ = A ⊕ B1 if the inputs differA B → Q00:0 01:1 10:1 11:0
The logic gates. A bubble on the output means NOT. NAND and NOR are ‘universal’: any circuit can be built from just one of them.

Written Boolean expressions use a dot for AND (A.B), a plus for OR (A + B), a bar over a letter for NOT (Ā) and ⊕ for XOR. You may also see ∧ for AND, ∨ for OR and ¬ for NOT. Just like in maths, brackets are worked out first, then NOT, then AND, then OR.

How a computer adds

A half adder circuit and a full adder built from two half addersHalf adderABSumCarry1 + 1 = 10 in binary: Sum 0, Carry 1Full adderHalfadder 1Halfadder 2ABCarry insum 1SumORCarry outChain full adders together to add whole bytes
Adders are how the ALU does arithmetic. A half adder adds two bits; a full adder also adds the carry from the column before.

Worked example: From a problem to a circuit

  1. An alarm (Q) should sound if the door is open (D) AND the system is armed (A), OR if the panic button (P) is pressed.
  2. Write the expression: Q = D.A + P.
  3. Circuit: D and A go into an AND gate; its output and P go into an OR gate; the OR output drives the alarm.
  4. Test some rows: D=1, A=0, P=0 gives 0 (door open, not armed: silent). D=1, A=1, P=0 gives 1. D=0, A=0, P=1 gives 1 (panic always works).

Turn each ‘and’ and ‘or’ in the description into a gate, then check the rows of a truth table.

Boolean laws that simplify expressions
LawAND formOR form
IdentityA.1 = AA + 0 = A
NullA.0 = 0A + 1 = 1
Same inputA.A = AA + A = A
InverseA.Ā = 0A + Ā = 1
De MorganNOT(A.B) = Ā + B̄NOT(A + B) = Ā.B̄

Simplifying with a Karnaugh map

A three-input Karnaugh map simplifying an expressionQ = A.B.C̄ + A.B.C + Ā.B.CB C00011110A0001010011Orange group: A = 1 and B = 1,C changes, so it drops out → A.BGreen group: B = 1 and C = 1,A changes, so it drops out → B.CSimplified: Q = A.B + B.C (fewer gates, same truth table)
A Karnaugh map puts neighbouring input patterns next to each other (00, 01, 11, 10), so groups of 1s show which inputs can be removed.

Key terms

Truth table
a table showing the output for every possible combination of inputs.
Universal gate
NAND or NOR: either can be combined to make every other gate.
Half adder
adds two bits: Sum = A XOR B, Carry = A AND B.
Full adder
adds two bits plus a carry in; built from two half adders and an OR gate.
Karnaugh map
a grid used to spot and remove unnecessary terms in a Boolean expression.

Think it through

How many rows does a truth table with 4 inputs have?

2⁴ = 16 rows.

Show how a NAND gate can act as a NOT gate.

Join both inputs together. If the input is 0, NAND(0, 0) = 1; if it is 1, NAND(1, 1) = 0, so the output is always the opposite of the input.

Simplify A.B + A.B̄.

Factor out A: A.(B + B̄) = A.1 = A. Whatever B is, the output equals A.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

From your lessons · F1

Extra detail from your teacher’s Unit 2 lessons. Practise it on the Diagram tasks page.

More gates from your logic booklet
GateOutput is 1 when…Notes
NANDNOT both inputs are 1a universal gate: any circuit can be built from NAND gates alone
NORboth inputs are 0also universal
XORthe inputs are differentused in half adders (sum bit) and parity checking
XNORthe inputs are the sameequality checking

Three-state (tri-state) logic adds a third output state, high impedance, where the output is effectively disconnected. It lets many devices share one bus wire: only the device that is enabled drives the bus, and the others ‘let go’.

Think it through

Why can a NAND gate be used to make a NOT gate?

Join both inputs together: if the input is 1, NAND gives 0; if it is 0, NAND gives 1, which is NOT.

Why is XOR used for the sum bit in a half adder?

1 + 0 and 0 + 1 give sum 1, while 0 + 0 and 1 + 1 give sum 0 (with a carry), which is exactly XOR.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • When does an OR gate output 0?

Open on YouTube ↗

How logic gates add binary numbers.

Watch and think:

  • Which two gates make a half adder?

Open on YouTube ↗

Stretch: the rules for simplifying Boolean expressions.

Watch and think:

  • Simplify A AND (A OR B).

Open on YouTube ↗

Section F2 · Before the workbook

Drawing how data moves

Your goal: Draw and test clear flow charts and system diagrams.

Show the order of steps

A flow chart represents a process. Use a start/end symbol, a process box for an action, an input/output symbol for reading or showing data, and a decision diamond for a question. Label the decision’s outgoing arrows, normally Yes and No. Every path should end or deliberately loop back.

Validate before choosing pass or retakeRead score0 to 100?inclusiveYes50 ormore?YesPASSNoRETAKENoInvalid score → end
Validate before choosing pass or retake. Follow the labels as you read.

Show how parts connect

A system diagram has a different focus: it shows components and the movement of data between them. A library diagram might show scanner, kiosk, network and database. Label what moves along each arrow. A box named Database alone does not explain what is read or written.

Check normal and edge cases

Walk through the diagram using sample inputs. Test values on either side of a boundary, invalid values and failures where relevant. If a score must be from 0 to 100, check validity before deciding pass or retake. State what happens next after an error.

Explain a diagram in words

Describe the order and the reason for each decision. Clear labels make the diagram easier to mark and easier for another developer to use. Do not add a branch simply to fill space: every branch must represent a rule.

Worked example

For a pass mark of 50, score 49 gives RETAKE and 50 gives PASS. Score 101 is invalid, even though it is greater than 50. That is why the range check comes first.

Pause and think

Where should an invalid score go in the flow chart?

Check your thinking

To a clearly labelled error output, followed by an explicit end or a deliberate loop back for a new input.

Go deeper · F2

The symbols

Standard flowchart symbolsStart / EndterminatorProcessa calculation or actionDecision?yes / no questionInput / Outputdata in or outSubroutinea named sub-processAconnectorflow lines show the order, and every one needs an arrowhead
Flowchart symbols. Using the standard shapes means anyone can read the chart.

A complete flowchart

Flowchart for topping up a bus pass with validationStartInput amount (£)Is amount between5 and 50?NoOutput “Enter £5 to £50”loop backYesbalance = balance + amountOutput new balanceEndTest with:• 20 (normal)• 5 and 50 (boundary)• 4 and 51 (just outside)• “ten” (erroneous)
A complete flowchart: one start, one end, a labelled decision and a loop that repeats until the input is valid.
Test plan for the top-up flowchart
Test typeExample valueExpected result
Normal20accepted; balance goes up by £20
Boundary (on the limit)5 and 50accepted
Boundary (just outside)4 and 51rejected with the message, then asked again
Erroneous“ten” or blankrejected with the message, then asked again

Seeing the whole system

System diagram of a school canteen payment systemStudenttaps cardParentuses app1. Take paymenttill2. Top up accountweb serviceKitchen managerD1 Accountscard ID, itemstop-up amountdaily sales reportread / updatebalanceread / updatebalanceOrange = people outside the system · Blue = processes · Open box = data store · Arrows = labelled data flows
A system (data flow) diagram shows who uses the system, what it does, where data is stored, and exactly which data moves where.

A flowchart shows the steps of one process in order. A system diagram shows the big picture: the people and other systems involved, the processes, the stored data and the data flowing between them. Label every arrow with the data it carries. If a process has data going in but nothing coming out, something is missing.

Key terms

Terminator
the rounded symbol marking the start or end of a flowchart.
Decision
a diamond with one question and labelled exits (usually Yes and No).
Iteration
a loop: steps that repeat until a condition is met.
Data store
somewhere data is kept in a system, such as a file or database table.
Boundary data
values at the edge of what is allowed, used to test the limits.

Think it through

What is wrong with a decision diamond that has three arrows coming out, none labelled?

A decision should ask one yes/no question with exactly two exits, and each exit must be labelled so the reader knows which way to go.

In the top-up flowchart, why is 50.01 a useful test value?

It is just above the upper limit, so it checks the program uses ‘50 or less’ correctly rather than accepting anything that starts with 50.

In the system diagram, what data flows would you add for a refund?

A refund request from the student or parent into a process, the refunded amount updating D1 Accounts, and a confirmation back to the person.

When you can explain the main idea in your own words, complete the matching activity. You can return here whenever you need help.

Watch

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • Which symbol shows a decision?

Open on YouTube ↗

A short revision video from the MrBrownCS series (also in the department video folder).

Watch and think:

  • What do the arrows in a DFD show?

Open on YouTube ↗