Back to Computer Science topics
All TopicsComputer Science HL564 flashcards

IB Computer Science HL — All Flashcards

Filter by unit or topic, or study everything at once.

Filter by Unit or Topic

All Topics

564 flashcards
Card 1 of 5641.1.1
1.1.1
Question

What is the function of the control unit (CU)?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All cards in this selection

Card 11.1.1definition
Question

What is the function of the control unit (CU)?

Answer

It controls and coordinates the CPU: it fetches and decodes instructions and sends control signals telling the other components what to do and when. It does no calculating itself.

Card 21.1.1definition
Question

What is the function of the arithmetic logic unit (ALU)?

Answer

It performs all arithmetic operations (add, subtract, multiply, divide) and logic operations (AND, OR, NOT, and comparisons) on data.

Card 31.1.1definition
Question

What does the program counter (PC) hold?

Answer

The address of the **next** instruction to be executed. It advances after each instruction is fetched.

Card 41.1.1comparison
Question

What is the difference between the MAR and the MDR?

Answer

The MAR holds the **address** being accessed; the MDR holds the **value** travelling to or from memory. Address versus data.

Card 51.1.1definition
Question

What does the instruction register (IR) hold?

Answer

The instruction currently being executed, held there while the CU decodes and carries it out.

Card 61.1.1definition
Question

What does the accumulator (AC) hold?

Answer

The number the ALU is working on — both the value going in and the answer coming out. ADD 5 turns a 12 in the accumulator into 17, in the same register.

Card 71.1.1concept
Question

Name the three buses and what each carries.

Answer

**Address bus** — the memory address (one-way, CPU → memory). **Data bus** — the data or instruction itself (two-way). **Control bus** — the CU's commands and timing signals (two-way).

Card 81.1.1concept
Question

Why does a multi-core processor not speed up every program?

Answer

Only work that can be divided between cores benefits. If each step depends on the previous result, the work cannot be split and extra cores sit idle.

Card 91.1.1concept
Question

Why does a CPU use registers rather than working directly in RAM?

Answer

Registers sit inside the CPU and can be reached almost instantly, whereas RAM is much slower. Holding working values in registers stops the ALU waiting on memory.

Card 101.1.2definition
Question

What is the role of a GPU?

Answer

To perform many simple calculations at the same time. It has thousands of small cores, which suits work made of many identical independent sums — pixels, machine learning, simulations.

Card 111.1.2comparison
Question

How does a GPU's architecture differ from a CPU's?

Answer

A CPU has a few powerful cores that handle complicated varied work in order. A GPU has thousands of simple cores that do the same calculation simultaneously.

Card 121.1.2example
Question

Give two non-graphics uses of a GPU and say why they fit.

Answer

Machine learning (multiplying huge grids of numbers) and large simulations (updating millions of independent points). Both repeat one calculation across many values.

Card 131.1.2concept
Question

When is a GPU a poor choice?

Answer

When the work is a chain of steps that each need the previous answer. Nothing can run in parallel, and GPU cores are individually weaker than CPU cores.

Card 141.1.2process
Question

How do the CPU and GPU divide a job between them?

Answer

The CPU runs the program, decides what needs doing, sends the repetitive part and its data to the GPU, and collects the result when it is finished. The GPU never chooses its own work.

Card 151.1.3comparison
Question

What is the core difference between a CPU and a GPU?

Answer

A **CPU** has a few powerful cores optimised for **latency** on one stream. A **GPU** has thousands of simple cores optimised for **throughput** on many values at once.

Card 161.1.3concept
Question

Why is a GPU poor at branching?

Answer

Its cores run in **lockstep** on the same instruction, so a branch forces some to idle while the others proceed.

Card 171.1.3concept
Question

What is the test for whether a GPU will help?

Answer

**Are the operations independent?** Can they run in any order, simultaneously, without needing each other's results?

Card 181.1.3example
Question

Why does training need a GPU but inference often not?

Answer

Training is enormous **parallel matrix arithmetic** over a whole dataset. Inference is one input, one pass — small enough for a CPU or a phone.

Card 191.1.3concept
Question

Why can moving a program to a GPU make it slower?

Answer

If the work is sequential or branch-heavy it cannot parallelise, each GPU core is slower than a CPU core, and the data must be **copied there and back**.

Card 201.1.4concept
Question

List primary memory from fastest to slowest.

Answer

Registers, then cache (L1, L2, L3), then RAM. Each step holds more and takes longer to reach.

Card 211.1.4definition
Question

What is the purpose of cache?

Answer

To hold recently used data and instructions in a small, very fast store close to the CPU, so most requests avoid the slower trip to RAM.

Card 221.1.4definition
Question

What is a cache hit and a cache miss?

Answer

A hit means the value is already in cache, so no trip to RAM is needed. A miss means it is not, so it is fetched from RAM and copied into cache for next time.

Card 231.1.4comparison
Question

What is the difference between RAM and ROM?

Answer

RAM is a large volatile working space holding programs in use; it empties when power is lost. ROM is small, non-volatile and read only, holding the start-up program.

Card 241.1.4concept
Question

Why is data copied into cache after a miss?

Answer

Because programs tend to reuse the same values shortly afterwards, so caching it turns the next request into a hit.

Card 251.1.5process
Question

What are the three stages of the fetch-decode-execute cycle?

Answer

Fetch the next instruction from memory, decode it in the control unit, then execute it — usually a calculation in the ALU. The cycle then repeats.

Card 261.1.5process
Question

Which registers are used during fetch?

Answer

The PC holds the address, which is copied to the MAR. Memory returns the instruction into the MDR, and it moves to the IR. The PC is then increased.

Card 271.1.5concept
Question

When is the program counter increased, and why then?

Answer

During fetch. A jump instruction works by writing a new address into the PC during execute — increasing it afterwards would overwrite the jump.

Card 281.1.5process
Question

What happens during decode?

Answer

The control unit reads the instruction held in the IR, works out which operation is needed, and sends control signals to the parts that will carry it out.

Card 291.1.5concept
Question

Which buses does a fetch use?

Answer

All three: the address bus carries the address out, the control bus carries the read signal, and the data bus brings the instruction back.

Card 301.1.6definition
Question

What is pipelining?

Answer

Overlapping the stages of the fetch–decode–execute cycle, so one instruction executes while the next is decoded and a third is fetched.

Card 311.1.6concept
Question

Does pipelining make one instruction faster?

Answer

**No.** It still passes through every stage. What improves is **throughput** — how many complete per second.

Card 321.1.6formula
Question

How long do n instructions take in a k-stage pipeline?

Answer

**k + (n − 1)** stage-times — the k being the one-off cost of filling the pipeline.

Card 331.1.6definition
Question

Name the three causes of a pipeline stall.

Answer

**Branches** (the next instruction is unknown), **data dependencies** (waiting for a result), **resource conflicts** (two stages want the same hardware).

Card 341.1.6concept
Question

Why is a deeper pipeline not always better?

Answer

It overlaps more work, but a **wrong branch prediction costs more** because there is more to discard and refill.

Card 351.1.7definition
Question

What is secondary storage and why is it needed?

Answer

Non-volatile storage that keeps data when the power is off. RAM empties at power-off, so anything kept permanently — files, programs, the operating system — lives here.

Card 361.1.7comparison
Question

Compare an SSD with an HDD.

Answer

An SSD uses flash memory with no moving parts: faster, quieter, more robust, but dearer per gigabyte. An HDD uses a spinning magnetic disk with a moving head: slower and more fragile, but much cheaper for the capacity.

Card 371.1.7example
Question

Name three types of external secondary storage and a use for each.

Answer

Portable SSD/HDD for backups and large files; flash drives or memory cards for carrying small amounts; optical discs for distributing identical content cheaply. NAS puts drives on a network for shared access.

Card 381.1.7definition
Question

What is eMMC?

Answer

Flash storage soldered onto the board of phones, tablets and budget laptops. Compact and inexpensive, but slower than an SSD and not replaceable.

Card 391.1.7concept
Question

How do you decide which storage suits a scenario?

Answer

Weigh capacity, speed, portability, cost and how many people need access at once. The right answer follows from the situation, not from which is newest.

Card 401.1.8definition
Question

What is compression?

Answer

Storing the same data in fewer bits. It works because real files repeat themselves, and smaller files need less storage and travel faster over a network.

Card 411.1.8comparison
Question

What is the difference between lossy and lossless compression?

Answer

Lossless can rebuild the original exactly — nothing is discarded, only written more briefly. Lossy permanently removes detail people are unlikely to notice, saving far more space but irreversibly.

Card 421.1.8process
Question

Explain run-length encoding with an example.

Answer

Each run of identical values is replaced by a count and the value. A row of six white pixels is stored as '6 white' — two values instead of six. Expanding it restores every original pixel.

Card 431.1.8concept
Question

When does run-length encoding make a file bigger?

Answer

When neighbouring values rarely repeat, such as a detailed photograph. Most runs are length one, so storing a count beside every value adds data rather than saving it.

Card 441.1.8example
Question

Which method suits text, and which suits photographs?

Answer

Text, code and spreadsheets need lossless — one altered character can change the meaning. Photographs, music and video use lossy, because small losses go unnoticed and the saving is much greater.

Card 451.1.9definition
Question

What is cloud computing?

Answer

Renting computing from a provider over the internet instead of buying and running the machines yourself. You pay for what you use and the provider keeps the hardware working.

Card 461.1.9comparison
Question

What is the difference between IaaS, PaaS and SaaS?

Answer

How far up the stack the provider takes over. IaaS gives you a machine and you install the OS upwards. PaaS runs the OS and runtime, and you supply your program. SaaS is the finished program — you just sign in.

Card 471.1.9example
Question

When should an organisation choose IaaS?

Answer

When it needs to choose the operating system or its version — for software with unusual requirements — and has technical staff able to configure and maintain the machines.

Card 481.1.9example
Question

When should an organisation choose SaaS?

Answer

When it needs a finished tool and has no technical staff. The provider handles updates, patching and backups, and the service is usable immediately.

Card 491.1.9concept
Question

What is the trade-off between control and convenience in cloud services?

Answer

Every layer you hand to the provider saves you work and removes a choice. Towards IaaS: more control, more responsibility for patching and setup. Towards SaaS: ready in minutes, but you accept the provider's features and versions and moving away later is hard.

Card 501.2.1process
Question

How do you convert a binary number to decimal?

Answer

Write the column values above it — 128 64 32 16 8 4 2 1 — and add the columns that have a 1 under them. 10110101 = 128 + 32 + 16 + 4 + 1 = 181.

Card 511.2.1process
Question

How do you convert a decimal number to binary?

Answer

Take the biggest column value that fits, subtract it, and repeat with what is left. 181: 128 fits (53 left), 32 fits (21), 16 fits (5), 4 fits (1), 1 fits (0) — so 10110101. Add the columns back to check.

Card 521.2.1concept
Question

Why does one hex digit equal exactly four bits?

Answer

Four bits can hold the values 0 to 15, which is exactly the range of a single hex digit (0 to F). So any four bits swap cleanly for one character.

Card 531.2.1process
Question

How do you convert binary to hexadecimal?

Answer

Group the bits in fours starting from the right, padding the leftmost group with zeros, then turn each group into its digit. 101101 is 0010 1101, which is 2D.

Card 541.2.1definition
Question

What are the hex digits above 9?

Answer

A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. To convert two hex digits to decimal, multiply the left by 16 and add the right: B5 = 11 × 16 + 5 = 181.

Card 551.2.2concept
Question

Why do the same bits mean different things in different files?

Answer

Because the meaning is an agreement held by the program reading them, not a property of the bits. 01000001 is 65 read by place value and A read through a character set.

Card 561.2.2process
Question

How is text stored in binary?

Answer

Each character is given a number by an agreed character set — 65 for A in ASCII — and that number is stored in binary. A string is those numbers one after another, so CAT is 67, 65, 84.

Card 571.2.2comparison
Question

What is the difference between ASCII and Unicode?

Answer

ASCII uses one byte per character and covers English. Unicode assigns numbers to every writing system, using more bytes per character where it needs them.

Card 581.2.2process
Question

How is an image stored in binary?

Answer

The picture is divided into a grid of pixels, and each pixel's colour is stored as numbers — one byte for greyscale, or three bytes for red, green and blue. More pixels means proportionally more storage.

Card 591.2.2process
Question

How are audio and video stored?

Answer

Audio: the height of the sound wave measured thousands of times a second, each measurement stored as a number. Video: a complete image 24 to 60 times a second, plus the audio — which is why video files are the largest.

Card 601.2.3definition
Question

What is a logic gate?

Answer

A component that takes one or two bits in and gives one bit out, always the same way for the same inputs. Gates wired together are what a CPU is physically built from.

Card 611.2.3definition
Question

When does each basic gate output 1?

Answer

AND: only when both inputs are 1. OR: when at least one input is 1. NOT: when the single input is 0. XOR: when the two inputs are different.

Card 621.2.3concept
Question

What does a circle on a gate's output mean?

Answer

Invert the output. AND with a circle is NAND, OR with a circle is NOR, XOR with a circle is XNOR — each is the original table with every output flipped.

Card 631.2.3comparison
Question

What is the difference between OR and XOR?

Answer

When both inputs are 1, OR gives 1 but XOR gives 0. XOR means the inputs are different, so it rules out the both-on case. A rule saying 'one or the other but not both' is XOR.

Card 641.2.3example
Question

Give a real use for AND and for OR.

Answer

AND: a microwave runs only if the door is closed and the timer is running — the rule says 'both'. OR: a car alarm sounds if any one of several doors opens — the rule says 'any'.

Card 651.2.4concept
Question

How many rows does a truth table need?

Answer

Two to the power of the number of inputs: 2 inputs give 4 rows, 3 give 8, 4 give 16. The rows are counted upwards in binary, so no combination is missed.

Card 661.2.4process
Question

How do you build a truth table from a logic circuit?

Answer

Give every gate its own column and work left to right. Fill the input columns first, then each gate column using only its own inputs, then combine those for the final output.

Card 671.2.4definition
Question

How do you write a circuit as a Boolean expression?

Answer

Use · for AND, + for OR and NOT for inversion. A circuit where an AND of A and B feeds an OR alongside an inverted C is X = (A·B) + NOT C.

Card 681.2.4process
Question

How does a Karnaugh map simplify an expression?

Answer

The outputs are arranged so neighbouring squares differ by one variable only. Circle the largest groups of adjacent 1s in sizes 1, 2, 4 or 8; for each circle keep the variables that stay constant and drop those that change.

Card 691.2.4concept
Question

Why simplify a Boolean expression?

Answer

A shorter expression is a circuit built from fewer gates — less hardware, less power consumption and fewer things to fail. For example A·B + A·(NOT B) simplifies to just A, needing no gates at all.

Card 701.2.5process
Question

How do you construct a logic diagram from a worded rule?

Answer

Write the Boolean expression first, draw the inputs down the left, draw the gates inside the brackets first, then feed their outputs into the final gate and label the output line.

Card 711.2.5definition
Question

How are the standard gate symbols recognised?

Answer

A flat-backed D shape is AND; a curved back with a pointed front is OR; a triangle with a circle is NOT. A circle on any output inverts it; an extra curve at the back makes it exclusive.

Card 721.2.5concept
Question

Which gate in an expression gets drawn first?

Answer

Whichever is inside the brackets. Its output feeds the gate outside them. Drawing them the other way round reverses the logic and is the most common mistake.

Card 731.2.5concept
Question

Which two Boolean rules save the most gates?

Answer

A + A·B = A, which drops a whole term when A alone is already enough, and A·(B + C) = A·B + A·C, which lets you factor out what is common. A repeated letter is the clue to look for.

Card 741.2.5process
Question

How do you check that a simplification is correct?

Answer

Build the truth table for the original expression and for the simplified one. Every row must match. This catches nearly every error, and a shorter expression is never proof on its own.

Card 751.3.1definition
Question

What is the role of an operating system?

Answer

It sits between programs and hardware doing two jobs: abstraction — giving programs one standard way to ask for anything — and resource management, deciding who gets the CPU, memory and devices, and when.

Card 761.3.1concept
Question

What does abstraction mean for an operating system?

Answer

Programs ask for what they need in one standard way whatever hardware is underneath. A program says 'save this file' without knowing which drive it is or how that drive works.

Card 771.3.1concept
Question

Why do programs not talk to hardware directly?

Answer

Because every program would then need to know every model of disk, printer and network card, and adding new hardware would mean rewriting all of them. With an OS, only a driver is added.

Card 781.3.1process
Question

How does the OS stop two programs interfering with each other?

Answer

It gives each program its own region of memory, queues their requests for shared devices, and refuses direct access to hardware or to its own memory — programs have to ask.

Card 791.3.1example
Question

What happens when a new model of printer is added?

Answer

A driver is added to the operating system, teaching it how to speak to that model. Every existing program keeps making the same standard request, so all of them work with it immediately.

Card 801.3.2definition
Question

Name the functions of an operating system.

Answer

Memory management, scheduling, file system, device management, security, accounting, graphical user interface, virtualization and networking — all running in the background at once.

Card 811.3.2definition
Question

What does memory management do?

Answer

Gives each program its own region of memory, tracks what is free, reclaims it when a program closes, and refuses any attempt to read or write memory belonging to another program.

Card 821.3.2definition
Question

What does device management do?

Answer

Talks to every device through its driver and queues requests, so two programs never try to use one device at the same moment and no program needs to know the device's model.

Card 831.3.2definition
Question

What is virtualization?

Answer

Making one physical machine appear to be several separate ones, each running its own operating system and unable to reach the others. It is how a single server hosts many customers.

Card 841.3.2process
Question

How does an OS stop one crashing program taking down the machine?

Answer

Each program has its own memory region and access outside it is refused; no program can address hardware directly. When one fails the OS stops it and reclaims its memory, leaving everything else running.

Card 851.3.3definition
Question

What is scheduling?

Answer

The rule the operating system uses to decide which process gets the CPU next, and for how long. A core runs one process at a time, so switching fast enough makes them appear simultaneous.

Card 861.3.3comparison
Question

Compare first come first served with round robin.

Answer

FCFS runs each process to completion in arrival order — simple, but one long job blocks everything behind it. Round robin gives each a fixed time slice then moves on, so everyone gets an early first turn, at the cost of time spent switching.

Card 871.3.3concept
Question

What is priority scheduling, and what is its risk?

Answer

The highest-priority waiting process runs next, so urgent work always goes first — essential for real-time systems. The risk is starvation: a low-priority process may never run if urgent work keeps arriving.

Card 881.3.3definition
Question

What is ageing?

Answer

Raising a process's priority the longer it has been waiting, so that even the lowest-priority work eventually reaches the front of the queue. It is the usual fix for starvation.

Card 891.3.3definition
Question

What is multilevel queue scheduling?

Answer

Processes are sorted into separate queues by what they are — interactive work in one, background batch work in another — and each queue gets its own scheduling rule and its own share of CPU time.

Card 901.3.4comparison
Question

What is the difference between polling and interrupts?

Answer

With polling the CPU repeatedly asks the device whether it is ready. With interrupts the device signals the CPU when it is ready, so the CPU can work uninterrupted until then.

Card 911.3.4process
Question

What happens when an interrupt occurs?

Answer

The CPU finishes its current instruction, saves where it was, runs a short routine that deals with the device, then restores the saved state and carries on. That saving and restoring is the overhead.

Card 921.3.4concept
Question

When is polling the better choice?

Answer

When the device is almost always ready, so nearly every check succeeds and you avoid saving state thousands of times a second; and when a guaranteed response time is needed, since the delay is bounded by the checking interval.

Card 931.3.4concept
Question

Why do battery-powered devices use interrupts?

Answer

Because the CPU can sleep between events, which uses very little power. Polling forces it awake to run checks that mostly find nothing, shortening battery life for no benefit.

Card 941.3.4concept
Question

What is the security concern with interrupt handling?

Answer

Interrupts are raised by devices, so a faulty or malicious device can raise them constantly and leave the CPU no time for other work. Polling cannot be flooded, because the CPU decides when to look.

Card 951.3.5comparison
Question

Concurrency or parallelism on a single core?

Answer

**Concurrency.** Several tasks are in progress but only one executes at any instant. Parallelism needs more than one core.

Card 961.3.5process
Question

What happens in a context switch?

Answer

**Save** the running process's registers and program counter, choose the next, **restore** its state, resume it exactly where it stopped.

Card 971.3.5concept
Question

Why is a context switch expensive beyond the save and restore?

Answer

The incoming process finds the **cache full of the previous one's data**, so its first memory accesses miss and are slow.

Card 981.3.5definition
Question

What are the four conditions for deadlock?

Answer

**Mutual exclusion, hold-and-wait, no pre-emption, circular wait** — all four at once. Break any one and deadlock cannot occur.

Card 991.3.5comparison
Question

Deadlock or starvation?

Answer

**Deadlock**: nobody can ever proceed. **Starvation**: the system runs fine but one process never gets a turn — fixed by **ageing**.

Card 1001.3.6definition
Question

Name the components of a control system.

Answer

**Sensor** → **ADC** → **microprocessor** → **actuator** → **feedback path** back to be measured again.

Card 1011.3.6comparison
Question

Open loop or closed loop?

Answer

**Open** acts without checking the result (a heater on a timer). **Closed** measures the result and acts on the **error** (a thermostat).

Card 1021.3.6concept
Question

What does feedback add?

Answer

The ability to correct **disturbances nobody predicted**. An open loop follows a plan; a closed loop pursues a goal.

Card 1031.3.6definition
Question

What is hysteresis?

Answer

A deliberate gap between the switch-on and switch-off points, so the actuator does not cycle constantly around the target and wear out.

Card 1041.3.6concept
Question

Why is control software real-time?

Answer

A correct answer **too late is a wrong answer** — braking 200 ms late is a crash. It must respond within a guaranteed time, not an average one.

Card 1051.3.7concept
Question

What decides how a control system is engineered?

Answer

The **consequence of being wrong**. The loop is always the same — sense, decide, act, measure — but a pacemaker and a thermostat face very different costs of failure.

Card 1061.3.7concept
Question

Why do critical systems use redundant sensors?

Answer

A failed sensor reading **zero looks like a genuine zero**. Comparing several means a disagreeing reading is treated as a fault rather than obeyed.

Card 1071.3.7definition
Question

What is a fail-safe state?

Answer

What the system does when it **cannot determine the situation** — a train applies the brakes, because stopping is safe and continuing is not.

Card 1081.3.7comparison
Question

Hard or soft real-time?

Answer

**Hard**: a missed deadline is a failure (braking, airbag). **Soft**: it degrades quality (a dropped video frame).

Card 1091.3.7definition
Question

What is automation bias?

Answer

People trusting a usually-correct system and **stopping checking it**, so the rare failure passes unchallenged.

Card 1101.4.1comparison
Question

Compiler or interpreter — what is the difference?

Answer

A **compiler** translates the whole program in advance into an executable. An **interpreter** translates and executes **line by line**, every run.

Card 1111.4.1comparison
Question

When is a syntax error reported by each?

Answer

**Compiler**: before the program runs, all at once. **Interpreter**: only when execution **reaches that line**.

Card 1121.4.1concept
Question

Why is interpreted code slower?

Answer

Translation happens **while it runs**, every time. Compiled code was already machine code before it started.

Card 1131.4.1definition
Question

What is bytecode for?

Answer

A compromise — compile **once** to an intermediate form, then run it on a virtual machine per platform. The compiler's checking with the interpreter's portability.

Card 1141.4.1concept
Question

Do compilers or interpreters catch logic errors?

Answer

**Neither.** Both run a wrong answer happily — they check the language's rules, not your intentions.

Card 1152.1.1definition
Question

What is a network, and what does it make possible?

Answer

Two or more devices connected so they can exchange data. That enables sharing hardware and files, communication between people, and reaching central services from anywhere.

Card 1162.1.1comparison
Question

What is the difference between a LAN and a WAN?

Answer

A LAN covers one site on cabling the organisation owns, making it fast and cheap. A WAN spans several distant sites over links it does not own — rented lines or the internet — so it is slower and costs more per unit of data.

Card 1172.1.1definition
Question

What is a PAN?

Answer

A personal area network: a few metres around one person, joining a phone to its earbuds or a smartwatch. Usually Bluetooth, chosen for very short range and very low power.

Card 1182.1.1definition
Question

What is a VPN and what does it do?

Answer

A virtual private network creates an encrypted tunnel across a public network, so a distant device behaves as though it were on the organisation's own LAN and can reach internal servers not exposed to the internet.

Card 1192.1.1concept
Question

Give one benefit and one drawback of networking an organisation's computers.

Answer

Benefit: one central copy of data that everyone works from and that stays current, plus shared hardware. Drawback: a single failure or break-in can affect everyone connected rather than one machine.

Card 1202.1.2comparison
Question

What is the difference between the internet and the worldwide web?

Answer

The internet is the global network of networks — the connections themselves. The web is one service running on it, made of pages fetched with HTTP. Email, calls and games are other services on the same internet.

Card 1212.1.2definition
Question

What is edge computing, and when is it the right choice?

Answer

Processing data where it is produced rather than sending it away. Right when an answer is needed in milliseconds, when raw data would flood the network, or when the device must keep working if its link fails — smart traffic lights, for example.

Card 1222.1.2definition
Question

What is a distributed system?

Answer

Many machines cooperating on one job with no single machine in charge. There is no single point of failure and it scales by adding machines, but keeping every machine agreed on the same answer is genuinely hard. A cryptocurrency blockchain is one.

Card 1232.1.2concept
Question

Give a benefit and a limitation of cloud computing.

Answer

Benefit: resources available on demand with no hardware to buy or maintain. Limitation: the service depends on both the provider's uptime and your own connection, and the costs recur indefinitely.

Card 1242.1.2concept
Question

What limits a mobile network?

Answer

Bandwidth is shared with every device nearby, so a busy area slows down, and coverage has gaps where there is no signal from a mast.

Card 1252.1.3comparison
Question

What is the difference between a switch and a router?

Answer

A switch moves traffic within one network, delivering each frame to the device it is addressed to; it cannot read IP addresses. A router moves traffic between networks, reading the destination IP address to choose the next hop.

Card 1262.1.3definition
Question

What does a gateway do?

Answer

Joins two networks that use different protocols, translating between them so traffic can cross. A plain router only forwards; a gateway also converts.

Card 1272.1.3definition
Question

What do a modem, a NIC and a wireless access point each do?

Answer

A modem converts between the network's digital signal and what the physical line carries. A NIC connects one machine to the network. A wireless access point lets devices join the LAN over radio instead of cable.

Card 1282.1.3concept
Question

Which TCP/IP layers do network devices work at?

Answer

Network access: switches, network interface cards, wireless access points and modems, handling frames and bits inside one network. Internet: routers and gateways, reading IP addresses to choose routes.

Card 1292.1.3definition
Question

What does a hardware firewall do?

Answer

Sits where the network meets the outside world and inspects traffic against its rules, blocking anything forbidden — on outgoing traffic as well as incoming.

Card 1302.1.4definition
Question

What is a network protocol?

Answer

An agreed set of rules for a conversation between machines: what gets said, in what order, and what a reply means. Machines from different makers can talk only because both follow the same rules.

Card 1312.1.4comparison
Question

What is the difference between TCP and UDP?

Answer

TCP numbers packets, checks they all arrived, asks again for missing ones and reorders them — so data arrives complete. UDP sends without checking and never resends, so it is faster but packets may be late, out of order or lost.

Card 1322.1.4concept
Question

When should UDP be used instead of TCP?

Answer

When timeliness matters more than completeness — live video, voice calls, online games. A late packet is already useless, so waiting for a resend delays everything after it for no benefit.

Card 1332.1.4comparison
Question

What does HTTPS add to HTTP?

Answer

Two guarantees: encryption, so nobody between the two ends can read the conversation, and identity, because a digital certificate proves the server really is who it claims to be.

Card 1342.1.4definition
Question

What is DHCP for?

Answer

Giving a device an IP address when it joins a network. The device asks, and a DHCP server assigns one from its pool for a limited time, instead of every device being configured by hand.

Card 1352.1.5definition
Question

Name the four TCP/IP layers in order.

Answer

**Application** (what it means) · **Transport** (did it all arrive) · **Internet** (which host) · **Link** (across this medium).

Card 1362.1.5definition
Question

What is encapsulation?

Answer

Each layer **wraps** what it was given in its own header on the way down, and **removes its own** on the way up.

Card 1372.1.5comparison
Question

IP or MAC — which changes at each hop?

Answer

The **MAC address** is rewritten at every hop, because it names only the next device on this link. The **IP address is unchanged** end to end.

Card 1382.1.5example
Question

TCP or UDP for a live video call?

Answer

**UDP.** TCP would retransmit a lost frame and hold everything behind it — but by then the frame is already in the past, and the pause freezes the call.

Card 1392.1.5concept
Question

What does layering buy?

Answer

Each layer depends only on the **interface** of the one below, so swapping Wi-Fi for Ethernet changes nothing above the link layer.

Card 1402.2.1concept
Question

Which five factors decide a network topology?

Answer

Reliability, transmission speed, scalability, data collisions and cost. No shape wins on all five, so every recommendation is a trade between them.

Card 1412.2.1definition
Question

Describe a star topology and its main weakness.

Answer

Every device connects to one central switch, which makes it cheap, easy to extend and nearly collision-free. Its weakness is that the switch is a single point of failure: if it fails, nothing reaches anything.

Card 1422.2.1comparison
Question

Why is a mesh topology reliable, and why is it rarely used at scale?

Answer

Every pair of devices has its own link, so there are many routes and no single link matters. But links grow roughly with the square of the devices — 5 need 10, 20 need 190 — so it is reserved for a few critical points.

Card 1432.2.1definition
Question

What is a hybrid topology?

Answer

Stars joined together, usually by more resilient links between them. Cheap where the devices sit, reliable where the traffic concentrates — which is what almost every real office and campus network looks like.

Card 1442.2.1concept
Question

Why are collisions rare on a star network?

Answer

Because the switch sends each frame only to the device it is addressed to, so devices are never competing for one shared line.

Card 1452.2.2definition
Question

What makes something a server?

Answer

It runs software that **waits for requests and responds**. A **role**, not a kind of hardware — one machine can run several.

Card 1462.2.2concept
Question

What does centralising on a server buy?

Answer

**One copy** of the data, permissions and backup in one place, shared powerful hardware, and one update reaching everyone.

Card 1472.2.2concept
Question

What is the main risk of client–server, and the answer?

Answer

A **single point of failure** and a bottleneck — answered by **redundant servers behind a load balancer**.

Card 1482.2.2comparison
Question

Client–server or peer-to-peer?

Answer

**Client–server** centralises control and consistency. **Peer-to-peer** has no single failure point and **gets faster as peers join**, but security and consistency are harder.

Card 1492.2.2comparison
Question

Scaling up or out?

Answer

**Up** — a bigger machine; simple, but has a ceiling and is still one failure point. **Out** — more machines; no ceiling, but the software must allow it.

Card 1502.2.3comparison
Question

What is the difference between client-server and peer-to-peer?

Answer

In client-server one machine holds the data and answers requests from the rest. In peer-to-peer there is no machine in charge — every machine holds a share and serves the others directly.

Card 1512.2.3concept
Question

Give a benefit and a drawback of client-server.

Answer

Benefit: one authoritative copy of the data, with security, access and backups controlled in a single place. Drawback: the server is a single point of failure and can bottleneck when many clients want it at once.

Card 1522.2.3concept
Question

Give a benefit and a drawback of peer-to-peer.

Answer

Benefit: no single point of failure, and capacity grows as more peers join, with no expensive server. Drawback: no central control over who sees what, data may disagree between peers, and availability depends on peers being online.

Card 1532.2.3example
Question

Why is online banking client-server?

Answer

Because an account balance must have one correct value held and controlled by the bank. Copies spread across customers' machines could disagree and none would be authoritative.

Card 1542.2.3example
Question

Why is a blockchain peer-to-peer?

Answer

By design: every participant holds a copy of the ledger and they agree among themselves what it says, so no single organisation decides what is true.

Card 1552.2.4definition
Question

What is network segmentation and why is it done?

Answer

Splitting one network into smaller separate ones. For performance, because less traffic competes on each segment, and for security, because a break-in or infection is contained where it started.

Card 1562.2.4definition
Question

What is subnetting?

Answer

Dividing the IP address range into smaller ranges, each its own network. Traffic between subnets must pass through a router, which is where rules can be enforced.

Card 1572.2.4definition
Question

What is a VLAN?

Answer

A logical grouping of devices configured on the switch, regardless of where each device is plugged in. Two machines in one room can be on different VLANs, and moving someone between groups is a setting rather than re-cabling.

Card 1582.2.4concept
Question

How does segmentation reduce congestion?

Answer

Broadcast traffic reaches only its own segment rather than every device, so on a network split six ways each device sees roughly a sixth as much — the cabling carries useful work instead of noise.

Card 1592.2.4concept
Question

What does segmentation cost an organisation?

Answer

It must be designed and maintained: wrong rules block legitimate work and forgotten rules leave gaps. Each crossing between segments also adds a routing step, and so a little delay.

Card 1602.3.1comparison
Question

What is the difference between IPv4 and IPv6?

Answer

IPv4 uses 32 bits, written as four numbers, giving about 4 billion addresses — which ran out. IPv6 uses 128 bits, written as groups of hex digits, so the supply is effectively unlimited.

Card 1612.3.1comparison
Question

What is the difference between a public and a private IP address?

Answer

A public address is unique across the whole internet and reachable from anywhere on it, which makes it scarce. A private address is used inside one network only and is not routable on the internet, so millions of networks can reuse the same one.

Card 1622.3.1process
Question

What does NAT do and why?

Answer

The router swaps each device's private address for the organisation's one public address on the way out, remembers which device asked, and swaps it back on the reply. It exists because public IPv4 addresses are scarce.

Card 1632.3.1comparison
Question

What is the difference between a static and a dynamic IP address?

Answer

A static address never changes, which anything that must always be findable needs — a web server, for instance. A dynamic address is assigned by DHCP when a device joins and may differ next time, which suits laptops and phones and reuses addresses efficiently.

Card 1642.3.1concept
Question

How does NAT contribute to security?

Answer

Private addresses are not routable on the internet, so nothing outside can address an internal machine directly — it can only reply to a conversation that machine started. A firewall is still needed as well.

Card 1652.3.2definition
Question

What are the three transmission media and what does each carry?

Answer

Twisted pair sends bits as electricity down copper, fibre optic sends them as light down glass, and wireless sends them as radio through the air.

Card 1662.3.2comparison
Question

What is the difference between attenuation and interference?

Answer

Attenuation is the signal getting weaker with distance — copper fades after about 100 m, fibre runs kilometres. Interference is something else corrupting the signal: electrical noise for copper, walls and other radios for wireless.

Card 1672.3.2concept
Question

Why is fibre used between buildings but not to every desk?

Answer

Between buildings its very low attenuation and immunity to interference are worth paying for. To a desk the run is short and the bandwidth is never used, so copper's much lower cost wins across hundreds of sockets.

Card 1682.3.2concept
Question

Why is wireless the least secure medium?

Answer

The signal leaves the building, so anyone nearby can receive it, whereas tapping copper or fibre requires physical access to the cable. That is why wireless must always be encrypted.

Card 1692.3.2concept
Question

What limits wireless bandwidth in practice?

Answer

It is shared with every device nearby, and walls, appliances and other networks all cause interference, so the rate a device actually achieves varies with conditions rather than being fixed.

Card 1702.3.3definition
Question

What is packet switching?

Answer

Data is cut into small packets, each sent independently across the network and joined back together at the destination. No line is reserved for a whole transfer, so many conversations share the network at once.

Card 1712.3.3definition
Question

What does a packet header contain?

Answer

The destination address, so routers know where to send it; the source address, so a reply or a request to resend can be sent back; and a sequence number saying where this piece belongs in the message.

Card 1722.3.3concept
Question

Why do packets arrive out of order?

Answer

Each packet is routed independently, and different routes take different times. This is expected behaviour, which is exactly why sequence numbers are in the header.

Card 1732.3.3comparison
Question

What do switches and routers each do in packet switching?

Answer

A switch delivers a frame to the one device it is addressed to within a single network. A router reads the destination IP address and chooses the next network to forward the packet to, one hop at a time.

Card 1742.3.3concept
Question

Why is packet switching better than reserving a line?

Answer

A reserved line is wasted whenever nobody is talking, and a break in it ends the conversation. Packet switching fills the gaps with other traffic and routes around breaks, and a lost packet means resending one packet rather than everything.

Card 1752.3.4definition
Question

What is a routing table?

Answer

A list held by a router saying, for each destination network, which neighbouring router to forward to. No router knows the whole path — it only ever chooses the next hop.

Card 1762.3.4definition
Question

What is static routing, and what are its advantages?

Answer

Routes typed in by an administrator, never changing unless edited. It uses no bandwidth or CPU, behaves completely predictably, has no protocol to go wrong, and cannot be misled by a false routing message.

Card 1772.3.4concept
Question

What is the main disadvantage of static routing?

Answer

It does not notice a broken link, so traffic keeps being sent into the fault until someone edits the table by hand. Every change is also manual, so the work grows with the size of the network.

Card 1782.3.4definition
Question

What is dynamic routing, and what does it cost?

Answer

Routers exchange information about what they can reach and build their own tables, adapting automatically when a link fails. It costs bandwidth for the messages, CPU and memory for the tables, and is harder to configure and diagnose.

Card 1792.3.4definition
Question

What is convergence?

Answer

The time between something changing on the network and every router agreeing on the new routes. During convergence traffic may loop or be dropped, which is the main weakness of dynamic routing.

Card 1802.4.1definition
Question

What does a firewall do?

Answer

Sits where the network meets the outside world and inspects every packet crossing it, allowing or dropping each one by rule — on outgoing traffic as well as incoming.

Card 1812.4.1comparison
Question

What is the difference between a whitelist and a blacklist?

Answer

A whitelist allows only what is listed and blocks everything else: safe by default but restrictive. A blacklist blocks only what is listed: convenient, but anything not yet known about gets through, so it is always a step behind.

Card 1822.4.1concept
Question

Why do outgoing firewall rules matter?

Answer

They stop an already-infected machine sending stolen data out or contacting whoever controls it. Most answers mention only incoming traffic, so this is a reliable extra mark.

Card 1832.4.1concept
Question

Name three things a firewall cannot protect against.

Answer

Traffic that never crosses it, such as malware on a USB stick or one internal machine infecting another; the contents of encrypted connections, which it cannot read; and attacks delivered over ports the rules legitimately allow.

Card 1842.4.1concept
Question

How does NAT contribute to security, and what are its limits?

Answer

Internal machines have private addresses that are not routable, so nothing outside can address them directly — only reply to conversations they start. But NAT does nothing about outgoing traffic, what an allowed connection carries, or anything inside the network.

Card 1852.4.2definition
Question

Vulnerability, attack or threat?

Answer

A **vulnerability** is the weakness. An **attack** is someone using it. A **threat** is the person or group who might.

Card 1862.4.2comparison
Question

Virus or worm?

Answer

A **virus** needs a user to run the infected file. A **worm** spreads **by itself** across a network, which is why it moves so fast.

Card 1872.4.2concept
Question

What does packet sniffing require?

Answer

**Unencrypted** traffic passing the attacker's machine. Encryption makes what is captured unreadable.

Card 1882.4.2concept
Question

Why does blocking one address not stop a DDoS?

Answer

It is **distributed** — traffic arrives from many machines at once, usually ordinary computers that were themselves compromised.

Card 1892.4.2concept
Question

Why are people the weakest link?

Answer

**Urgency defeats caution** and authority is rarely questioned. One person in a thousand clicking is enough, and emailing thousands costs nothing.

Card 1902.4.3definition
Question

What is defence in depth?

Answer

Layered controls, so that **one failing does not end the matter** — assume the firewall will eventually be got past.

Card 1912.4.3concept
Question

Which single control gives the most protection?

Answer

**Multi-factor authentication.** It turns a stolen password into a failed login, and stolen passwords cause most breaches.

Card 1922.4.3concept
Question

What does a firewall not stop?

Answer

Anything **already inside**, and anything carried over a connection it was configured to **allow** — such as malware in ordinary web traffic.

Card 1932.4.3concept
Question

Why must backups be tested and offline?

Answer

An untested backup fails when needed, and one reachable from the network can be **encrypted by ransomware along with everything else**.

Card 1942.4.3concept
Question

Why can a strict policy reduce security?

Answer

People **work around** what they cannot follow — writing passwords down, using personal accounts, and not reporting mistakes.

Card 1952.4.4comparison
Question

What is the difference between symmetric and asymmetric cryptography?

Answer

Symmetric uses one key to both lock and unlock — fast, but the key must reach the other end safely. Asymmetric uses two matched keys: a public one anyone may have and a private one that never leaves, so nothing secret has to travel.

Card 1962.4.4concept
Question

Which key encrypts and which decrypts in asymmetric cryptography?

Answer

For confidentiality, the recipient's public key encrypts and only their matching private key can decrypt. That is why the public key can be handed to anyone without weakening anything.

Card 1972.4.4definition
Question

What is a digital certificate?

Answer

An organisation's public key together with its identity, signed by a certificate authority the browser already trusts. It proves the public key really belongs to who it claims, which a bare public key cannot.

Card 1982.4.4process
Question

Why does HTTPS use both symmetric and asymmetric encryption?

Answer

Asymmetric solves the problem of agreeing a key safely but is slow. So it is used once to agree a symmetric key, and all the actual traffic is then encrypted symmetrically because that is much faster for bulk data.

Card 1992.4.4concept
Question

Why does key management matter as much as the encryption itself?

Answer

Keys must be generated properly, stored where nobody else can reach them, replaced periodically and revoked immediately if they leak. A private key that escapes makes every message ever sent with it readable, however strong the algorithm.

Card 2003.1.1definition
Question

What is a relational database?

Answer

A database that stores data in tables and links those tables together with keys, so each fact is stored once in the table it belongs to and other tables point at it rather than copying it.

Card 2013.1.1comparison
Question

What is the difference between a primary key, a composite key and a foreign key?

Answer

A primary key uniquely identifies each row in its table. A composite key does that using two or more columns together, when no single column is unique. A foreign key holds a primary key value from another table, which is how the link is made.

Card 2023.1.1concept
Question

Give three benefits of a relational database.

Answer

Reduced duplication, because each fact is stored once; data integrity, because the database enforces rules such as refusing an invalid foreign key; and consistency, because changing a fact in one place is seen by everyone.

Card 2033.1.1concept
Question

Give three limitations of a relational database.

Answer

A rigid schema that must be decided up front and is disruptive to change; poor handling of unstructured data such as documents and images; and difficulty scaling very large volumes across many machines.

Card 2043.1.1concept
Question

Why is storing everything in one large table a problem?

Answer

The same fact gets written out on every row that mentions it. Changing it means finding every copy, and missing one leaves the data contradicting itself.

Card 2053.2.1definition
Question

What are the three database schema levels?

Answer

Conceptual — the entities and relationships the organisation cares about. Logical — those turned into tables, columns, keys and data types. Physical — how the chosen system actually stores it, including files and indexes.

Card 2063.2.1definition
Question

What does a conceptual schema contain, and what does it leave out?

Answer

It contains the entities and the relationships between them, in language the organisation recognises. It deliberately omits keys, data types and any choice of database product.

Card 2073.2.1definition
Question

What belongs to the physical schema?

Answer

How the chosen system stores the data: files on disk, indexes, partitions and storage settings. This is where performance decisions live, and it must be redone if you change database product.

Card 2083.2.1definition
Question

What is data independence?

Answer

The schema levels are insulated from each other, so a change at one does not force a change at another. Adding an index at the physical level alters no query written against the logical schema.

Card 2093.2.1concept
Question

Why describe one database three times?

Answer

So the meaning can be agreed with non-technical people before technical choices are made, so storage can change without breaking programs, and so the same logical design can be built on different database systems.

Card 2103.2.2definition
Question

What does an ERD show?

Answer

The entities a database stores and the relationships between them. Each box is one kind of thing that will become a table; each line is a relationship, labelled with the verb joining them.

Card 2113.2.2comparison
Question

What is the difference between cardinality and modality?

Answer

Cardinality is how many — one or many, drawn as a bar or a crow's foot. Modality is whether the relationship is compulsory — mandatory drawn as a second bar, optional as a circle.

Card 2123.2.2process
Question

How do you work out a relationship's cardinality?

Answer

Say it as a sentence in both directions. 'A teacher teaches many classes' and 'a class is taught by one teacher' together give one-to-many, with the crow's foot on the Class end.

Card 2133.2.2concept
Question

Why must a many-to-many relationship be resolved?

Answer

A column holds only one value, so neither table can hold several foreign keys. It is replaced by a linking entity with one row per pair, keyed on both foreign keys together.

Card 2143.2.2concept
Question

Where does the foreign key go in a one-to-many relationship?

Answer

In the table on the many side. A Class holds TeacherID, because the alternative would need a Teacher row to hold an unknown number of class columns.

Card 2153.2.3definition
Question

What does a column's data type do?

Answer

It says what kind of value may be stored, and the database refuses anything that does not fit. It also decides what can be done with the values — arithmetic on numbers, true ordering on dates.

Card 2163.2.3process
Question

How do you decide a column's data type?

Answer

Ask whether you will ever calculate with it, compare it, or sort it. If yes it needs a real type; if it is only ever displayed — a phone number or postcode — text is correct however numeric it looks.

Card 2173.2.3example
Question

Why store a phone number as text rather than a number?

Answer

A numeric type drops the leading zero, so 07700 becomes 7700, and no arithmetic is ever done on a phone number anyway.

Card 2183.2.3concept
Question

What three things go wrong if a date is stored as text?

Answer

Sorting compares character by character so the order is wrong; date ranges and age calculations become impossible; and nothing rejects an impossible date such as 31/02/2026.

Card 2193.2.3concept
Question

Why must a foreign key have the same data type as the primary key it references?

Answer

Otherwise the join either fails or silently returns nothing — values that look equal to a person are not equal to the database when their types differ.

Card 2203.2.4process
Question

How do you turn an ERD into tables?

Answer

Each entity becomes a table and each relationship becomes a foreign key. In a one-to-many the foreign key goes in the many table; a many-to-many needs a linking table holding both foreign keys.

Card 2213.2.4concept
Question

Why does the foreign key go in the many table?

Answer

Because a column holds one value. A Class row holds one TeacherID easily, whereas a Teacher row would need an unknown number of columns to hold every class they take.

Card 2223.2.4comparison
Question

What is the difference between a composite key and a concatenated key?

Answer

A composite key uses two or more columns together as the primary key, keeping them separate and queryable. A concatenated key glues values into a single column, such as 2026-S1, which then has to be pulled apart to filter on either part.

Card 2233.2.4definition
Question

What are entity, referential and domain integrity?

Answer

Entity integrity: a primary key is never empty or duplicated. Referential integrity: a foreign key must match an existing row. Domain integrity: a value must fit its column's data type.

Card 2243.2.4concept
Question

Why enforce rules in the database rather than in the program?

Answer

Rules enforced by the database apply to every program that touches the data, including ones written years later. Rules enforced in a program apply only to that program.

Card 2253.2.5definition
Question

What is a functional dependency?

Answer

One column's value determining another's. Knowing a StudentID tells you the student's name, so Name is functionally dependent on StudentID. Normal forms are rules about which dependencies are allowed where.

Card 2263.2.5definition
Question

What do 1NF, 2NF and 3NF each require?

Answer

1NF: every cell holds one value and every row is uniquely identified. 2NF: no non-key column depends on only part of a composite key. 3NF: no non-key column determines another non-key column.

Card 2273.2.5definition
Question

What is a partial-key dependency?

Answer

A non-key column depending on only part of a composite primary key. With a key of StudentID and Club, StudentName depends on StudentID alone. It can only arise when the key is composite.

Card 2283.2.5definition
Question

What is a transitive dependency?

Answer

A non-key column determining another non-key column. Club determines Teacher and Teacher determines Room, so Room depends on Club only indirectly — which breaks 3NF.

Card 2293.2.5concept
Question

Why normalise, beyond saving space?

Answer

To prevent update problems, where one copy of a repeated fact is changed and others are not; insert problems, where a new club with no members has nowhere to live; and delete problems, where removing the last member loses the club's details too.

Card 2303.2.6process
Question

What are the four steps to normalise a design to 3NF?

Answer

List every piece of data with sample rows; make cells atomic and choose the key; move out anything depending on part of a composite key; move out any non-key column determined by another non-key column.

Card 2313.2.6concept
Question

Why write sample rows before normalising?

Answer

Because functional dependencies are far easier to see in actual data than in a list of column names — repeated values make the repeated facts visible.

Card 2323.2.6process
Question

How do you find a transitive dependency?

Answer

In each table ask whether any non-key column determines another non-key column. If so, both move to a new table, and the determining column stays behind as a foreign key.

Card 2333.2.6process
Question

How do you check a finished 3NF design?

Answer

Pick a fact the scenario needs and follow the keys to find it. If you cannot reach it, a link is missing; if you find it in two places, the design is not yet in 3NF.

Card 2343.2.6concept
Question

How many tables should a typical scenario produce?

Answer

More than feels natural — a scenario with eight columns usually becomes about four tables. Finishing with one or two almost always means a transitive dependency was missed.

Card 2353.2.7definition
Question

What is denormalisation?

Answer

Deliberately storing some data more than once so that reads need fewer joins and run faster. It is a considered engineering trade, not a mistake.

Card 2363.2.7comparison
Question

What does denormalising gain and what does it risk?

Answer

It gains faster reads and simpler queries. It risks the same fact being stored in two places and disagreeing, requires every update to find every copy, and brings back insert and delete problems.

Card 2373.2.7concept
Question

When is denormalising justified?

Answer

When data is read far more often than it is written — reports, dashboards and data warehouses that are loaded in bulk and then only read. Never for frequently-written data such as bookings or stock levels.

Card 2383.2.7process
Question

How should the risk of denormalising be managed?

Answer

Keep the normalised tables as the authoritative source and rebuild the denormalised copy from them, so there is always one correct version to fall back on.

Card 2393.2.7concept
Question

Why should you normalise before denormalising?

Answer

Because you should design in 3NF, run it, and find out where it is actually slow. Denormalising before a measured problem exists gives away correctness for a speed gain you cannot demonstrate.

Card 2403.3.1comparison
Question

What is the difference between DDL and DML?

Answer

DDL, data definition language, changes the structure of the database — tables, columns, keys. DML, data manipulation language, reads and changes the rows inside tables that already exist. The test is shape versus contents.

Card 2413.3.1definition
Question

Name the main DDL statements and what each does.

Answer

CREATE makes a new table with its columns, types and keys; ALTER changes an existing structure, such as adding a column; DROP removes a table entirely, along with everything in it.

Card 2423.3.1definition
Question

Name the main DML statements and what each does.

Answer

SELECT reads rows matching a condition; INSERT INTO adds a new row; UPDATE SET changes values in existing rows; DELETE removes rows from a table.

Card 2433.3.1comparison
Question

What is the difference between DELETE and DROP?

Answer

DELETE removes rows and the table stays, ready for more data — it is DML. DROP removes the table itself, with its structure and all its contents — it is DDL.

Card 2443.3.1concept
Question

Who runs DDL and who runs DML?

Answer

DDL is run rarely, by a database administrator, when the design genuinely changes. DML is run constantly, by the application, every time somebody uses the system.

Card 2453.3.2definition
Question

What does the ON condition in a JOIN do?

Answer

It names the two columns that must match — almost always a foreign key and the primary key it points at. Without it, every row of one table pairs with every row of the other.

Card 2463.3.2process
Question

In what order are SQL clauses applied?

Answer

FROM and JOIN decide which rows exist, WHERE filters them, GROUP BY collapses them, HAVING filters the groups, SELECT picks the columns, and ORDER BY sorts. SELECT is written first but applied near the end.

Card 2473.3.2comparison
Question

What is the difference between WHERE and HAVING?

Answer

WHERE filters individual rows before grouping. HAVING filters groups after grouping, and is the only place a condition on a count or total can go, because that value does not exist until GROUP BY has run.

Card 2483.3.2definition
Question

How does LIKE with the % wildcard work?

Answer

% stands for any run of characters. 'Sm%' matches anything starting Sm, '%son' anything ending son, and '%ann%' anything containing ann.

Card 2493.3.2concept
Question

When is DISTINCT needed in a joined query?

Answer

When the join can legitimately produce the same row more than once — a student belonging to two clubs would otherwise appear twice in a list of names.

Card 2503.3.3definition
Question

What do INSERT, UPDATE and DELETE each do?

Answer

INSERT INTO adds a new row; UPDATE SET changes values in rows that already exist; DELETE removes rows. All three are DML, so the table's structure is untouched.

Card 2513.3.3concept
Question

What happens if an UPDATE or DELETE has no WHERE clause?

Answer

It applies to every row in the table, with no warning, no confirmation and no undo once committed. The safe habit is to write the WHERE clause first and test it with a SELECT.

Card 2523.3.3concept
Question

Why does an index make reads fast and writes slow?

Answer

It is a separate sorted structure the database can go straight to, instead of reading every row. But every INSERT, UPDATE or DELETE on an indexed column must update that structure as well as the row.

Card 2533.3.3concept
Question

What is index fragmentation, and how is it fixed?

Answer

After many changes an index's entries no longer sit in an efficient order, so it gradually stops helping. Reorganising tidies it in place; rebuilding constructs it from scratch. Both are usually scheduled for quiet hours.

Card 2543.3.3example
Question

Why might indexes be dropped before a bulk load and rebuilt afterwards?

Answer

With indexes present, every one of the millions of inserted rows updates every index individually. Building each index once at the end is a single sorted pass, which is far cheaper.

Card 2553.3.4definition
Question

Name the five SQL aggregate functions.

Answer

**COUNT**, **SUM**, **AVG**, **MIN**, **MAX** — each collapsing many rows into one value.

Card 2563.3.4comparison
Question

WHERE or HAVING?

Answer

**WHERE** filters rows **before** grouping. **HAVING** filters groups **after**. A condition on an aggregate can only be HAVING.

Card 2573.3.4comparison
Question

COUNT(*) or COUNT(column)?

Answer

**COUNT(*)** counts rows. **COUNT(column)** counts rows where that column is not null — the difference between 1 and 0 after a LEFT JOIN.

Card 2583.3.4concept
Question

What do aggregates do with nulls?

Answer

**AVG, SUM, MIN and MAX ignore them** — 10 rows with 3 nulls means AVG divides by 7. COUNT(*) is the exception.

Card 2593.3.4concept
Question

Which columns must appear in GROUP BY?

Answer

Every column in SELECT that is **not inside an aggregate**, or there is no single value to show for the group.

Card 2603.3.5definition
Question

What is a database view?

Answer

A **stored query with a name**, used like a table. It holds **no data of its own**.

Card 2613.3.5concept
Question

Why is a view always up to date?

Answer

It stores the **query**, not the result, so every read runs it afresh — there is nothing to go stale.

Card 2623.3.5concept
Question

How does a view provide security?

Answer

Grant rights on the **view only**. With no permission on the underlying table, a user cannot reach a column the view does not select.

Card 2633.3.5comparison
Question

Does a view make a query faster?

Answer

**No.** The underlying query runs on every read. A **materialised view** stores the result and is fast, but is only current to the last refresh.

Card 2643.3.5concept
Question

Can you update through a view?

Answer

Sometimes — a simple view over one table often yes. One with a **join, GROUP BY or aggregate** usually not: there is no single underlying row to change.

Card 2653.3.6definition
Question

What is a transaction?

Answer

A group of statements treated as **one indivisible unit** — COMMIT makes them permanent, ROLLBACK undoes them all.

Card 2663.3.6definition
Question

What does ACID stand for?

Answer

**Atomicity** (all or none), **Consistency** (rules still hold), **Isolation** (no interference), **Durability** (survives a crash).

Card 2673.3.6concept
Question

Which property stops two withdrawals from the same balance?

Answer

**Isolation** — achieved by locking the row, so the second transaction waits and then reads the updated balance.

Card 2683.3.6concept
Question

What does durability actually require?

Answer

That the change has reached **non-volatile storage** before COMMIT returns — which is why a commit waits for the disc.

Card 2693.3.6definition
Question

What is a deadlock, and what happens?

Answer

Each transaction holds what the other wants, so neither can proceed. The database **aborts one**, which then retries.

Card 2703.4.1definition
Question

Name five database types.

Answer

**Relational** (tables), **document** (varying fields), **key-value** (fetch by key), **graph** (nodes and edges), **column-family** (columns grouped).

Card 2713.4.1comparison
Question

When does a graph database beat relational?

Answer

When the **relationships are the question** — "friends of friends" is one traversal against a self-join per level in SQL.

Card 2723.4.1concept
Question

What can a key-value store not do?

Answer

**Query the value.** You fetch by key or not at all, which is why it suits caches and sessions.

Card 2733.4.1concept
Question

What does a document store give up for its flexibility?

Answer

**Joins** and enforced schema — so data is duplicated, and update anomalies return.

Card 2743.4.1concept
Question

Is NoSQL an upgrade on relational?

Answer

**No, a trade.** Relational remains right for most business data because it enforces structure and transactions.

Card 2753.4.2definition
Question

What is a data warehouse for?

Answer

**Analysing history** — few enormous reads — as opposed to an operational database recording many small transactions.

Card 2763.4.2process
Question

What does ETL stand for?

Answer

**Extract** from each source, **Transform** into one consistent shape, **Load** into the warehouse. Transform is where most of the work is.

Card 2773.4.2concept
Question

Why is a warehouse denormalised?

Answer

So analytical queries **avoid joins**. It is safe because the warehouse is rebuilt in bulk and never edited, so update anomalies cannot arise.

Card 2783.4.2concept
Question

How current is a data warehouse?

Answer

Only as current as the **last load** — often nightly. It never answers "what is happening right now".

Card 2793.4.2concept
Question

Is a data warehouse a backup?

Answer

**No.** It holds **transformed** data, not the originals, so the business could not be restored from it.

Card 2803.4.3comparison
Question

What is the difference between OLAP and data mining?

Answer

**OLAP** answers a question you already have. **Data mining** finds patterns you did not ask about — one confirms, the other suggests.

Card 2813.4.3comparison
Question

Drill down or roll up?

Answer

**Drill down** to finer detail (year → quarter → month). **Roll up** to a coarser summary (store → region → country).

Card 2823.4.3comparison
Question

Slice or dice?

Answer

**Slice** fixes **one** dimension to a single value. **Dice** fixes **several** dimensions to ranges.

Card 2833.4.3definition
Question

Name four data mining techniques.

Answer

**Association** (occur together), **clustering** (groups), **classification** (predict a label), **anomaly detection** (unlike the rest).

Card 2843.4.3concept
Question

Why is a mined pattern only a candidate?

Answer

Test enough combinations and some look significant **by chance**. It must be validated on data not used to find it — and it is never causation.

Card 2853.4.4comparison
Question

Replication or fragmentation — what is the difference?

Answer

**Replication** keeps copies of the same data (availability, read speed). **Fragmentation** splits data between machines (capacity, writes).

Card 2863.4.4concept
Question

What happens if a shard's machine fails?

Answer

**That portion becomes unavailable** — unless the shard is also replicated, which is why real systems do both.

Card 2873.4.4definition
Question

What is the consistency–availability trade-off?

Answer

During a network partition you either **refuse to answer** (consistent) or **answer from a reachable copy** (available, possibly stale). You cannot have both.

Card 2883.4.4example
Question

Which would a bank choose, and which a social feed?

Answer

A bank chooses **consistency** — better to refuse than to allow a double withdrawal. A social feed chooses **availability** — a late post is harmless.

Card 2893.4.4definition
Question

What is eventual consistency?

Answer

Copies are brought into step **shortly after** a write, not instantly — so a read straight after a write can return the old value.

Card 2904.1.1concept
Question

What decides which type of machine learning applies?

Answer

What the algorithm is given to learn from: labelled examples, unlabelled data, or an environment to act in. Answer that and you have named the type.

Card 2914.1.1comparison
Question

What is the difference between supervised and unsupervised learning?

Answer

Supervised learns from labelled examples to predict the label of something new. Unsupervised is given no labels and finds groups or structure the data already contains — but cannot say what those groups mean.

Card 2924.1.1definition
Question

What is reinforcement learning?

Answer

An agent acts in an environment, receives a reward or penalty for what happens, and over thousands of attempts learns which actions earn the most reward. It needs no dataset, but must be allowed to fail repeatedly.

Card 2934.1.1definition
Question

What makes deep learning different from other approaches?

Answer

It uses many layers, each building on what the last found — edges, then shapes, then whole objects — so it works out its own features. The cost is needing a great deal of data and being hard to explain.

Card 2944.1.1definition
Question

What is transfer learning and when is it used?

Answer

Starting from a model already trained on a related task and retraining only its final layers on your own data. It is used when you have too few examples to train from scratch — hundreds rather than millions.

Card 2954.1.2comparison
Question

Why do training and using a model need different hardware?

Answer

Training repeats the same calculation over millions of examples for hours or days, needing massive parallel processing. Using the trained model is one small calculation per question, which a phone or camera can often do.

Card 2964.1.2definition
Question

What are GPUs and TPUs used for in machine learning?

Answer

Both provide the massive parallel processing training needs. A GPU has thousands of general simple cores; a TPU is a chip designed specifically for machine-learning calculations.

Card 2974.1.2comparison
Question

What is the difference between an ASIC and an FPGA?

Answer

An ASIC is built for one task and can never do another — the fastest and most power-efficient option, but useless if the task changes. An FPGA can be reconfigured after manufacture, so it is slower but adaptable.

Card 2984.1.2concept
Question

When is an edge device the right place to run a model?

Answer

When a trained model must answer immediately on the spot — in a camera or a vehicle. It gives millisecond responses, keeps data off the network, and works even when the connection drops.

Card 2994.1.2concept
Question

Why does storage speed matter when training?

Answer

Training datasets run to terabytes and must be read fast enough to keep the processors busy. Slow storage leaves very expensive hardware sitting idle and waiting.

Card 3004.2.1definition
Question

What is data cleaning?

Answer

Finding and fixing what is **missing, duplicated, inconsistent or wrong** before training — because a model learns the faults along with everything else.

Card 3014.2.1example
Question

Why is a recorded 0 often a missing value?

Answer

Many systems encode "not recorded" as 0. A blood pressure of 0 is impossible, so the model learns from a value that never occurred.

Card 3024.2.1concept
Question

Why can deleting rows with missing values bias a dataset?

Answer

Absence is **rarely random**. If a value is missing more often for one group, deleting those rows removes that group disproportionately.

Card 3034.2.1concept
Question

What does a duplicate record do to training?

Answer

It counts **twice**, so that record's characteristics carry double weight in what the model learns.

Card 3044.2.1concept
Question

Should outliers always be removed?

Answer

No. An **error** should be; a **genuine extreme** should not — in fraud detection the outliers are exactly the target.

Card 3054.2.2definition
Question

What is a feature?

Answer

One **input column** the model is given. Feature selection decides which ones it sees.

Card 3064.2.2definition
Question

What is data leakage?

Answer

A feature containing the answer, or one **not available at prediction time**. Test accuracy looks superb and then collapses in production.

Card 3074.2.2concept
Question

Why is an identifier a bad feature?

Answer

It is unique per row, so the model **memorises** rather than learns — perfect on training data, useless on anything new.

Card 3084.2.2definition
Question

Name four kinds of feature worth dropping.

Answer

**Irrelevant** (no relationship), **redundant** (duplicates another), **constant** (no information), **identifier** (memorises) — and above all **leaking**.

Card 3094.2.2concept
Question

Does dropping a sensitive attribute stop discrimination?

Answer

No. Other features **proxy** for it — postcode, school, employment history — and the model finds those instead.

Card 3104.2.3definition
Question

What is dimensionality reduction?

Answer

Describing the same data with **fewer features** while keeping as much of the variation as possible.

Card 3114.2.3definition
Question

What is the curse of dimensionality?

Answer

More features means an **exponentially larger space**, so data becomes sparse, distances lose meaning, and exponentially more records are needed.

Card 3124.2.3comparison
Question

Feature selection or extraction — what is the difference?

Answer

**Selection** keeps a subset of the original columns. **Extraction** builds new features from combinations of them, as PCA does.

Card 3134.2.3process
Question

What does PCA do?

Answer

Finds the directions along which the data varies **most** and uses them as the new axes, so the first few components carry most of the information.

Card 3144.2.3concept
Question

What is always lost in dimensionality reduction?

Answer

Some **variation** — it is lossy by construction — and with extraction, **interpretability**: a component cannot be named in plain words.

Card 3154.3.1definition
Question

What does linear regression predict?

Answer

A **continuous** value, by fitting $y = mx + c$ through the data.

Card 3164.3.1process
Question

How is the best line chosen?

Answer

By minimising the **sum of squared residuals** — least squares. Squaring stops errors cancelling and punishes large ones heavily.

Card 3174.3.1concept
Question

What does the gradient mean?

Answer

The change in the predicted value **per unit** of the input — for example price per square metre. It is the interpretable part of the model.

Card 3184.3.1concept
Question

Why is extrapolation dangerous?

Answer

The line continues forever but reality may not. The model has no notion of the range it was trained on and reports **no uncertainty**.

Card 3194.3.1comparison
Question

Regression or classification?

Answer

"**How much?**" is regression — a number on a scale. "**Which one?**" is classification — a category.

Card 3204.3.10concept
Question

What does model selection weigh besides accuracy?

Answer

**Explainability**, speed at prediction, data needed, cost, and **which error is worse** — any of which can outrank accuracy.

Card 3214.3.10concept
Question

Why measure a baseline first?

Answer

If the complicated model barely beats a majority-class guesser or a linear fit, the **complexity is not earning its place**.

Card 3224.3.10concept
Question

Is a 0.3 percentage-point accuracy gap meaningful?

Answer

Usually **no** — within the variation between cross-validation folds it is noise. Decide on the criteria that genuinely differ.

Card 3234.3.10example
Question

When does interpretability outrank accuracy?

Answer

When a decision must be **justified or audited** — lending, medicine, recruitment. An unexplainable model is then not deployable at any accuracy.

Card 3244.3.10process
Question

How must candidate models be compared?

Answer

On the **same** training and test data, ideally the same **cross-validation folds**, with the test set opened **once** at the end.

Card 3254.3.2definition
Question

What does classification predict?

Answer

Which **category** something belongs to, learned from labelled examples — binary (two) or multi-class.

Card 3264.3.2comparison
Question

Precision or recall — which is which?

Answer

**Precision**: of those flagged, how many really were? **Recall**: of the real cases, how many were caught?

Card 3274.3.2concept
Question

Why is accuracy misleading on rare events?

Answer

A model answering "no" every time scores 99.9% on a 1-in-1,000 condition and finds **nothing**. Ask what a majority guesser would score.

Card 3284.3.2concept
Question

What does lowering the decision threshold do?

Answer

Catches **more real cases** at the cost of **more false alarms** — recall rises, precision falls. It is a human judgement about which error is worse.

Card 3294.3.2example
Question

Which error is worse: spam filter or cancer screening?

Answer

Opposite. Spam: a **false positive** (a real email lost) is worse. Screening: a **false negative** (a missed tumour) is worse.

Card 3304.3.3comparison
Question

Parameter or hyperparameter — how do you tell?

Answer

Ask whether it was **chosen before training started**. If the model worked it out from the data, it is a parameter.

Card 3314.3.3concept
Question

What does the learning rate control?

Answer

How big a step each update takes. **Too high** overshoots the minimum and never settles; **too low** never arrives in the time available.

Card 3324.3.3process
Question

Why are three data sets used?

Answer

**Training** learns parameters, **validation** chooses hyperparameters, **test** is opened once to report. Tuning on the test set leaks it.

Card 3334.3.3definition
Question

What is cross-validation?

Answer

Splitting into k folds, training on k−1 and testing on the held-out one, rotating — so every record is tested exactly once.

Card 3344.3.3comparison
Question

Grid search or random search?

Answer

**Grid** tries every combination and is exponentially expensive. **Random** samples within ranges and usually finds something good sooner, because few hyperparameters matter much.

Card 3354.3.4definition
Question

What does clustering do?

Answer

Groups similar records with **no labels** — the groups are the output, which is what makes it unsupervised.

Card 3364.3.4process
Question

What are the steps of k-means?

Answer

Choose k, place centres at random, **assign** each point to the nearest, **move** each centre to the mean of its members, repeat until stable.

Card 3374.3.4concept
Question

Why can k-means give different answers on the same data?

Answer

The starting centres are **random** and it finds a **local** optimum, so where it settles depends on where it began.

Card 3384.3.4concept
Question

Why must features be scaled before clustering?

Answer

k-means uses **distance**, so a feature measured in thousands dominates one measured in units — income would decide the clusters entirely.

Card 3394.3.4concept
Question

What does clustering NOT tell you?

Answer

What the clusters **mean**. It returns "cluster 0, 1, 2"; naming them is a human interpretation that nothing validates.

Card 3404.3.5definition
Question

What does association rule learning find?

Answer

Items that **occur together**, written {A} → {B}. Unsupervised — nothing is being predicted.

Card 3414.3.5formula
Question

Support, confidence, lift — what is each?

Answer

**Support** = both ÷ all baskets. **Confidence** = both ÷ baskets with A. **Lift** = confidence ÷ how often B occurs anyway.

Card 3424.3.5concept
Question

What does lift tell you?

Answer

**>1** occur together more than chance (real) · **=1** independent · **<1** less than chance. It is what separates a finding from a popular item.

Card 3434.3.5concept
Question

Why is confidence alone misleading?

Answer

It rewards whatever is **popular**. 80% confidence is worthless if the consequent appears in 90% of baskets anyway — lift would be 0.89.

Card 3444.3.5concept
Question

Is {A} → {B} the same as {B} → {A}?

Answer

**No.** Support is identical, but **confidence differs** — everyone buying caviar buys bread; almost nobody buying bread buys caviar.

Card 3454.3.6comparison
Question

How does reinforcement learning differ from supervised learning?

Answer

Supervised learning is told **the correct answer**. Reinforcement learning is told only **how well things went** — a reward, often long afterwards.

Card 3464.3.6definition
Question

Name the components of a reinforcement learning system.

Answer

**Agent**, **environment**, **state**, **action**, **reward** — and the **policy**, which maps states to actions and is what is actually learned.

Card 3474.3.6definition
Question

What is the exploration–exploitation trade-off?

Answer

Whether to **exploit** the best action known so far or **explore** another in case it is better. Only exploiting never improves; only exploring never benefits.

Card 3484.3.6definition
Question

What is credit assignment?

Answer

Working out **which** of many earlier actions earned a reward that arrived much later — a game won after 200 moves.

Card 3494.3.6concept
Question

What is reward hacking?

Answer

The agent maximising **exactly what was measured** rather than what was meant. The system works perfectly; the objective was wrong.

Card 3504.3.7process
Question

What are the stages of a genetic algorithm?

Answer

**Population → fitness → selection → crossover → mutation → repeat.**

Card 3514.3.7concept
Question

When is a genetic algorithm appropriate?

Answer

When the search space is **too large to enumerate**, no formula gives the answer, candidates can be **scored**, and "good enough" is acceptable.

Card 3524.3.7comparison
Question

Crossover or mutation — which introduces novelty?

Answer

**Mutation.** Crossover only recombines values already in the population; mutation can produce one present in neither parent.

Card 3534.3.7concept
Question

What happens if the mutation rate is too high?

Answer

It becomes a **random search** — good solutions are destroyed as fast as they are found.

Card 3544.3.7concept
Question

Does a genetic algorithm find the optimal solution?

Answer

**No** — a good one. There is no optimality guarantee, and two runs can give different answers.

Card 3554.3.8definition
Question

What does one unit in a neural network compute?

Answer

Each input **times a weight**, summed, **plus a bias**, passed through an **activation function**.

Card 3564.3.8definition
Question

Name the three kinds of layer.

Answer

**Input** (one unit per feature), **hidden** (where the work happens), **output** (one unit per class).

Card 3574.3.8concept
Question

Why is a non-linear activation essential?

Answer

Without it, stacked layers collapse into a **single weighted sum** — a hundred layers would have the power of one.

Card 3584.3.8process
Question

What is backpropagation?

Answer

Working **backwards** from the error to find each weight's contribution, so every weight can be nudged in the direction that reduces it.

Card 3594.3.8concept
Question

What does training change, and what does it not?

Answer

It changes the **weights and biases**. The number of layers, units and the activation function are **hyperparameters**, fixed beforehand.

Card 3604.3.9process
Question

What does convolution do in a CNN?

Answer

Slides a small **filter** of weights across the input, multiplying and summing at each position to produce a **feature map** of where that pattern occurs.

Card 3614.3.9concept
Question

Why are shared weights important?

Answer

The **same** filter is used at every position, so a feature is recognised **wherever it appears** — and one detector costs a handful of weights rather than a set per location.

Card 3624.3.9definition
Question

What is pooling for?

Answer

Keeping the strongest value in each block: **fewer numbers** to carry forward, and tolerance to small shifts in position.

Card 3634.3.9concept
Question

What do successive CNN layers learn?

Answer

**Edges**, then shapes built from edges, then objects built from shapes — a hierarchy that is learned rather than designed.

Card 3644.3.9concept
Question

Why is flattening an image a problem?

Answer

It **destroys the geometry** — the network no longer knows which pixels were adjacent — and a 200×200 colour image gives 120,000 inputs, needing millions of weights.

Card 3654.4.1concept
Question

Where does bias in a machine-learning model come from?

Answer

From training data that reflects the world as it was. A model learns the patterns in past decisions, so historical unfairness is reproduced at scale — and wearing the appearance of objectivity, which makes it harder to challenge.

Card 3664.4.1concept
Question

Why does removing a sensitive field not remove bias?

Answer

Because other fields stand in for it — a postcode can imply background, a school can imply income — and the model finds those substitutes on its own.

Card 3674.4.1concept
Question

Why must fairness be measured per group rather than overall?

Answer

A model can be 95% accurate overall and far worse for a small group, because that group barely affects the average. The headline number hides exactly the problem you are looking for.

Card 3684.4.1concept
Question

What is the accountability problem with machine learning?

Answer

When a model causes harm it is unclear who answers for it — the developer, the organisation using it, or the operator. 'The system decided' gives the affected person nobody to appeal to.

Card 3694.4.1definition
Question

Name three ethical concerns about machine learning beyond bias.

Answer

Transparency, since a complex model cannot easily explain its decision; privacy and consent, because data given for one purpose is used to train models; and environmental impact, since training large models uses very large amounts of energy and water.

Card 3704.4.2concept
Question

Why must ethical guidelines be continually reassessed?

Answer

Because they were written for the technology that existed at the time. Something genuinely new does not break the old rules — it sits outside them, doing something nobody thought to allow or forbid.

Card 3714.4.2process
Question

What four lenses can you apply to any new technology?

Answer

Individual rights: can a person refuse, and appeal? Privacy: what is collected, and did bystanders agree? Equity: who is left out or served worse? Society: what changes when everyone has it?

Card 3724.4.2concept
Question

What is the ethical concern with quantum computing?

Answer

It would eventually break much of today's encryption. Because encrypted data can be stolen and stored now and decrypted later, the risk begins before the machines exist — so organisations need quantum-resistant encryption already.

Card 3734.4.2comparison
Question

Why is augmented reality a greater privacy concern than a fixed camera?

Answer

The glasses go everywhere the wearer goes, recording everyone they meet without any consent, and they can also alter what the wearer sees — which raises the question of who chooses that.

Card 3744.4.2concept
Question

Why is pervasive AI a concern even when each individual system is defensible?

Answer

Because of the accumulation. When jobs, loans, healthcare and policing all involve models, large parts of a person's life are decided by systems they cannot see, question or appeal against.

Card 3755.1.1definition
Question

What are the six parts of a problem specification?

Answer

Problem statement, objectives and goals, input specification, output specification, constraints and limitations, and evaluation criteria.

Card 3765.1.1concept
Question

What makes an objective testable?

Answer

You can describe the test that would settle it in one sentence. 'Return results in under five seconds on 10,000 records' can be tried; 'be fast' is an opinion and never can be.

Card 3775.1.1definition
Question

What goes in an input specification?

Answer

Each input item, its data type, its valid range, and where it comes from — for example 'Member ID: a whole number between 1 and 99999, entered by staff'. The validation rules come straight from this.

Card 3785.1.1concept
Question

What is most often forgotten in an output specification?

Answer

What happens when there is nothing to show. Stating 'a message if there are no results' is a cheap and reliable mark.

Card 3795.1.1concept
Question

Why write evaluation criteria before building?

Answer

So the target cannot be moved afterwards. Deciding what counts as success once you already know what you built is not judging the work at all.

Card 3805.1.2definition
Question

What are the four concepts of computational thinking?

Answer

Decomposition — breaking a large problem into smaller separate ones. Pattern recognition — finding what repeats. Abstraction — deciding what to leave out. Algorithmic design — writing the steps precisely.

Card 3815.1.2definition
Question

What does abstraction actually mean?

Answer

Deciding what to leave out, and why — not being vague. A route-planning app treats a road as a start point, an end point and a travel time, dropping surface, width and street name as irrelevant.

Card 3825.1.2definition
Question

What is pattern recognition for?

Answer

Finding the parts of a problem that are the same, so one solution serves many cases. Every track event needs the same steps, so solving it once covers the 100 m, the 200 m and the relay.

Card 3835.1.2definition
Question

What is algorithmic design?

Answer

Setting out the steps in order, precisely enough that someone else could follow them without asking a question. It does not require code — plain steps or a flowchart are enough.

Card 3845.1.2concept
Question

Does computational thinking require programming?

Answer

No. The guide states it explicitly: it is a toolkit of problem-solving techniques. Planning a sports day, designing a database and diagnosing a fault all use the same four.

Card 3855.1.3process
Question

What four questions turn an unfamiliar problem into a solvable one?

Answer

What are the pieces (decomposition)? What repeats (pattern recognition)? What can I ignore (abstraction)? What are the steps (algorithmic design)? Then trace the steps on a small example by hand.

Card 3865.1.3example
Question

How is designing a database an example of computational thinking?

Answer

Decomposition splits one wide table into several; abstraction decides which attributes each entity actually needs; pattern recognition notices that every many-to-many relationship needs a linking table.

Card 3875.1.3example
Question

Where does abstraction matter most in machine learning?

Answer

In choosing which features to give the model and which to leave out. It is usually the single most important decision in a machine-learning project.

Card 3885.1.3concept
Question

Why trace an algorithm by hand before writing code?

Answer

Because it turns a plausible-looking algorithm into one you know is right, and it finds the error before any code exists to debug. It is also very often exactly what the exam asks for.

Card 3895.1.3concept
Question

Why does Paper 2 set a question with no code?

Answer

To test whether you can take a problem described in words and make it solvable without reaching for a programming language — which is what computational thinking means.

Card 3905.1.4definition
Question

What are the standard flowchart symbols?

Answer

Rounded box for Start/End, slanted box for Input/Output, rectangle for Process, diamond for Decision with two labelled exits, arrow for Flowline, and a small circle for Connector.

Card 3915.1.4concept
Question

How is a loop shown on a flowchart?

Answer

There is no loop symbol. A loop is a decision diamond with a flowline going back up to it — follow the arrows and the loop is obvious.

Card 3925.1.4process
Question

How do you trace a flowchart reliably?

Answer

Draw the table first with one column per variable plus output; write a new row for every change; write the comparison out in full at every diamond; and add to the output column only when an output box is reached.

Card 3935.1.4concept
Question

What is the commonest tracing error?

Answer

The boundary case. When the test is 'count at most N', the loop still runs when the two values are equal — one more time than most people expect.

Card 3945.1.4definition
Question

How many exits does a decision symbol have?

Answer

Exactly two, labelled Yes and No. A diamond drawn with one exit or with three is drawn incorrectly.

Card 3956.1.1definition
Question

What is a variable, and what does its data type decide?

Answer

A named place in memory holding one value. Its data type says what kind of value it is, which decides both what can be stored there and what operations work on it.

Card 3966.1.1definition
Question

Name the five data types and what each holds.

Answer

Integer: a whole number. Decimal: a number with a fractional part. Char: a single character. String: a sequence of characters. Boolean: exactly True or False.

Card 3976.1.1concept
Question

Why does + behave differently on numbers and strings?

Answer

It adds numbers and joins strings, so 12 + 1 gives 13 but "12" + "1" gives "121". Mixing the two — "12" + 1 — fails, and is one of the commonest bugs.

Card 3986.1.1comparison
Question

What is the difference between a local and a global variable?

Answer

A local variable is created inside a function, cannot be seen from outside, and is destroyed when the function ends. A global variable is created outside any function and is visible throughout the program.

Card 3996.1.1concept
Question

Why are local variables preferred?

Answer

If a local value is wrong, the cause is inside that function. If a global value is wrong, any part of the program could have changed it — so the bug could be anywhere.

Card 4006.1.2concept
Question

Where do string positions start, and what does a slice include?

Answer

Positions start at 0, and a slice excludes its end position. So text[2:5] gives the characters at 2, 3 and 4 — three characters, which is simply 5 minus 2.

Card 4016.1.2definition
Question

What do len, find and split each do?

Answer

len gives the number of characters. find gives the position where a piece of text starts, or -1 if it is absent. split breaks a string into a list at each occurrence of a separator.

Card 4026.1.2concept
Question

Do string methods change the original string?

Answer

No. upper, lower and replace all return a new string and leave the original untouched. To keep the change you must assign it back: text = text.upper().

Card 4036.1.2process
Question

How do you split an email address at the @?

Answer

Find the position of the @, then take everything before it and everything from one position after it: at = email.find("@"); user = email[:at]; domain = email[at + 1:]. The +1 skips the @ itself.

Card 4046.1.2concept
Question

When is split better than using fixed positions?

Answer

Whenever the parts can vary in length. code[0:2] works only while the prefix is exactly two characters, whereas splitting at the separator survives a longer or shorter one.

Card 4056.1.3definition
Question

What is an exception?

Answer

A problem that appears while the program is running, rather than a mistake in the code's grammar. Without handling the program simply stops; with handling it can report the problem and carry on.

Card 4066.1.3definition
Question

What do try, except and finally each do?

Answer

try holds only the lines that might fail. except (catch in Java) handles one specific kind of failure. finally runs whether or not anything failed, and is where files get closed.

Card 4076.1.3definition
Question

What are the three sources of failure to look for?

Answer

Unexpected input, usually from people; unavailable resources such as a missing file or unresponsive network; and logic errors, where the code ran on values nobody planned for.

Card 4086.1.3concept
Question

When should you validate rather than catch?

Answer

When the problem is predictable and inside your control — an empty list, a zero divisor. Catch the things outside it: files, networks and databases, which can fail between your check and your use.

Card 4096.1.3concept
Question

Why must closing a file go in finally?

Answer

If a line inside try fails, control jumps straight to except and any later lines in try never run. finally runs either way, so the file is closed rather than left open holding a system resource.

Card 4106.1.4definition
Question

What are the three kinds of error?

Answer

Syntax errors stop the program running at all. Run-time errors stop it partway with a message. Logic errors let it run perfectly and produce the wrong answer — and only the third needs debugging.

Card 4116.1.4definition
Question

Name the four debugging techniques and what each is for.

Answer

Trace table: work through by hand, no tools needed — the exam method. Print statements: show a value at a chosen point. Breakpoints: pause and inspect every variable. Step-by-step execution: run one line at a time and watch values change.

Card 4126.1.4process
Question

What is the method for narrowing down a bug?

Answer

Write down what you expected for one specific input; find the first value that is wrong, halving the search each time; look only at the lines that set that value; then change one thing and test again.

Card 4136.1.4concept
Question

Where do logic errors usually hide?

Answer

At the boundary: an empty list, a single item, the first and last positions, and values that are exactly equal. If a program is wrong, test the boundary before anything else.

Card 4146.1.4concept
Question

Why change only one thing at a time?

Answer

If the change works, you know which change fixed it. If it does not, you have not added a new set of suspects to investigate.

Card 4156.2.1comparison
Question

What is the difference between a static and a dynamic data structure?

Answer

A static structure has its size fixed when it is created, in one contiguous block of memory. A dynamic structure grows and shrinks while the program runs, taking more memory only when it needs it.

Card 4166.2.1concept
Question

Why is reading a position in a static array fast?

Answer

Everything sits in one block with items of equal size, so the address of item 20 is simply the start plus twenty item-widths. It is one calculation, with nothing searched for — O(1).

Card 4176.2.1concept
Question

What does a dynamic structure cost when it grows?

Answer

When it outgrows its block it must claim a bigger one and copy everything across. That single operation is expensive, but it happens rarely, so the average cost of adding an item stays low.

Card 4186.2.1concept
Question

When should you choose a static structure?

Answer

When the size is genuinely fixed — twelve months, seven days, sixty-four squares — or when a very large amount of data is scanned repeatedly and both speed and predictable memory matter.

Card 4196.2.1concept
Question

Why is a fixed-size array wrong for an unknown number of items?

Answer

You must guess a maximum. Guess too small and it overflows or silently discards data; guess too large and most of the memory is never used — with still no guarantee the guess was enough.

Card 4206.2.2concept
Question

How are items in a list addressed?

Answer

By position, starting at 0. A list of four items has positions 0, 1, 2 and 3, so asking for position 4 is an error — the commonest list bug there is.

Card 4216.2.2definition
Question

How do you add to and remove from a dynamic list?

Answer

append adds at the end, insert(position, value) adds anywhere and shifts the rest along. remove(value) takes out the first match, and pop() removes the last item and gives it back.

Card 4226.2.2concept
Question

Why must you not remove items while looping over a list?

Answer

Removing shifts everything after it down one place while the loop counter moves up, so items get skipped silently. Build a new list instead, or loop over a copy.

Card 4236.2.2definition
Question

What is a 2D list and how is it addressed?

Answer

A list whose items are themselves lists — a grid. It is addressed [row][column], always in that order: grid[1][2] is row 1, column 2.

Card 4246.2.2concept
Question

Why does visiting every cell of a grid need a nested loop?

Answer

The outer loop gives you each row, which is itself a list; the inner loop reaches the individual values inside it. That is also why scanning a grid is O(rows × columns).

Card 4256.2.3definition
Question

What is a stack?

Answer

A structure that allows adding and removing at one end only, the top. The last item put in is the first taken out — last in, first out, or LIFO.

Card 4266.2.3definition
Question

What are the four stack operations?

Answer

push adds an item on top; pop removes the top item and returns it; peek returns the top item without removing it; isEmpty says whether there is anything in the stack at all.

Card 4276.2.3concept
Question

Why are all stack operations O(1)?

Answer

Every operation touches only the top. Nothing is shifted along and nothing is searched for, so the cost is the same whether the stack holds three items or three million.

Card 4286.2.3example
Question

Give three uses of a stack.

Answer

Undo, where the most recent action must be reversed first; the call stack, since function calls unwind in reverse order; and checking that brackets match, because the most recent opening bracket must close first.

Card 4296.2.3concept
Question

What causes a stack overflow?

Answer

A stack that keeps growing with nothing being popped until it runs out of memory — usually a function that calls itself with no way to stop.

Card 4306.2.4definition
Question

What is a queue?

Answer

A structure added to at one end and taken from at the other: items join at the back and leave from the front. The first item in is the first out — first in, first out, or FIFO.

Card 4316.2.4definition
Question

What are the four queue operations?

Answer

enqueue adds an item at the back; dequeue removes the item at the front and returns it; front returns the next item out without removing it; isEmpty says whether anyone is waiting.

Card 4326.2.4concept
Question

Why is a plain list a poor implementation of a queue?

Answer

Removing from the front of a list shifts every remaining item down one place, which is O(n) every time. A proper queue structure removes from the front in constant time.

Card 4336.2.4concept
Question

What one question chooses between a stack and a queue?

Answer

Does the most recent item matter most, or the one that has waited longest? Most recent means a stack; longest waiting means a queue.

Card 4346.2.4example
Question

Give three uses of a queue.

Answer

Print jobs, so they print in the order sent; process scheduling, where round robin takes the front process and returns it to the back; and buffering data such as keystrokes or network packets, which must be handled in arrival order.

Card 4356.3.1concept
Question

Why are sequence errors hard to spot?

Answer

Both lines are perfectly valid, so nothing is reported. The program runs to completion and simply produces the wrong answer.

Card 4366.3.1concept
Question

What causes an infinite loop?

Answer

The thing the loop's test depends on never changes — most often because the counter is increased inside a branch that does not always run, so the test can never become false.

Card 4376.3.1process
Question

Where do setup, work and reporting belong relative to a loop?

Answer

Set up before the loop — totals at 0, counters at their start. Do the work for one item inside. Print or return the finished result after, since printing inside shows a running value rather than the final one.

Card 4386.3.1definition
Question

What is deadlock and how is it prevented?

Answer

Two parts of a program each hold a resource the other is waiting for, so neither can move. It is prevented by having every part claim shared resources in the same fixed order.

Card 4396.3.1process
Question

What three questions check that a sequence is right?

Answer

Is every value set before it is used? Does the thing the loop tests always change? Is the result used after it is complete rather than during? Those three catch nearly every sequence error.

Card 4406.3.2comparison
Question

What is the difference between an else-if chain and separate ifs?

Answer

A chain runs exactly one branch and skips the rest once a match is found. Separate ifs test every condition, so several may run or none. Use a chain for mutually exclusive cases and separate ifs for independent ones.

Card 4416.3.2concept
Question

Why must a range chain be ordered narrowest first?

Answer

The chain stops at the first true test. If mark >= 50 is tested before mark >= 70, every mark of 70 or more matches the first test, so the later branch is unreachable.

Card 4426.3.2definition
Question

What do and, or and not do?

Answer

and requires both sides to be true; or requires at least one; not reverses the result. They are the same logic as the AND, OR and NOT gates, with the same truth tables.

Card 4436.3.2concept
Question

What is wrong with 'if day == "Sat" or "Sun"'?

Answer

The second half is a bare piece of text rather than a comparison, and non-empty text counts as true — so the whole condition is always true. Each side of an or must be a full comparison.

Card 4446.3.2comparison
Question

What is the difference between == and =?

Answer

== compares two values and produces a Boolean; = assigns a value to a variable. Writing = where == belongs is a classic error.

Card 4456.3.3process
Question

How do you choose between a counted and a conditional loop?

Answer

Ask whether you know how many times it must repeat before it starts. Yes means a counted loop (for); no means a conditional one (while), which repeats as long as a condition holds.

Card 4466.3.3concept
Question

How many times does a counted loop of 5 run, and what values does the counter take?

Answer

Five times, taking 0, 1, 2, 3 and 4. It starts at 0 and stops before 5 — the same rule as a string slice, and the same source of off-by-one errors.

Card 4476.3.3concept
Question

Can a while loop run zero times?

Answer

Yes. The condition is tested before the first pass, so if it is already false the body never runs at all. That is correct behaviour and often exactly what is wanted.

Card 4486.3.3concept
Question

Where should a counter or total be set up?

Answer

Before the loop. Setting it inside resets it on every pass, so the final answer would be just the last value rather than the accumulated one.

Card 4496.3.3concept
Question

Why do nested loops produce O(n²) work?

Answer

The inner loop runs completely for every single pass of the outer loop, so the total work is rows times columns. That is where quadratic complexity comes from.

Card 4506.3.4definition
Question

What is a function?

Answer

A named block of code that does one job, is given data through parameters, and hands back a result with return. Written once, it can be called anywhere and fixed in one place.

Card 4516.3.4comparison
Question

What is the difference between a parameter and an argument?

Answer

The parameter is the name in the function's definition — the placeholder. The argument is the actual value supplied when the function is called.

Card 4526.3.4concept
Question

What are the benefits of modularisation?

Answer

Reusable: one definition serves every caller. Maintainable: a fix applies everywhere at once and faults trace to one function. Testable: each function can be tested on its own. And work can be split between people.

Card 4536.3.4concept
Question

Why pass values in as parameters rather than using globals?

Answer

A function told what it needs works anywhere, can be tested on its own, and cannot be broken by something changing elsewhere in the program.

Card 4546.3.4concept
Question

Why should a function return rather than print?

Answer

A returned value can be stored, compared or displayed by the caller, and the function can be tested. A function that only prints can do none of those.

Card 4556.4.1definition
Question

What does Big O describe?

Answer

How an algorithm's work grows as the data grows — the shape of the growth, not the time in seconds, which depends on the machine it runs on.

Card 4566.4.1process
Question

How do you work out an algorithm's complexity?

Answer

Count the loops over the data. No loop is O(1), one loop is O(n), a loop inside a loop is O(n²), and halving what is left at each step is O(log n).

Card 4576.4.1concept
Question

Why is 2n + 5 written as O(n)?

Answer

Big O describes the shape of the growth, and constants and lower-order terms do not change that shape. Doubling the data still doubles the work.

Card 4586.4.1comparison
Question

What is the difference between time and space complexity?

Answer

Time complexity is how the number of steps grows; space complexity is how the extra memory grows, not counting the input. Bubble sort is O(n²) time but O(1) space, because it sorts in place.

Card 4596.4.1concept
Question

What does O(n²) mean in practice?

Answer

Twice the data means four times the work, and ten times the data means a hundred times. At 1,000 items that is a million steps; at 10,000 it is a hundred million.

Card 4606.4.2process
Question

How does linear search work, and what does it cost?

Answer

It checks each item in turn until it finds the target or runs out, returning the position or -1. Best case O(1) if the target is first, worst case O(n) if it is last or absent.

Card 4616.4.2process
Question

How does binary search work?

Answer

Look at the middle item. If it equals the target, stop. If it is too small the target is to the right, so move low to mid + 1; if too big, move high to mid - 1. Each step discards about half the remaining list.

Card 4626.4.2concept
Question

Why must binary search have sorted data?

Answer

Discarding half depends on knowing which half the target would be in, which only holds if the list is in order. On unsorted data it does not run slowly — it returns the wrong answer.

Card 4636.4.2concept
Question

How does binary search terminate?

Answer

When low passes high, meaning there is nothing left to search. It then returns -1 to indicate the target is absent.

Card 4646.4.2comparison
Question

How do the two searches grow with the data?

Answer

Doubling the list doubles linear search's worst case, but adds only one comparison to binary search's. Sixteen items need at most four binary comparisons; a million need about twenty.

Card 4656.4.3process
Question

How does bubble sort work?

Answer

It compares each neighbouring pair and swaps any that are out of order. Each pass sends the largest remaining value to the end, so the next pass can compare one fewer pair.

Card 4666.4.3process
Question

How does selection sort work?

Answer

For each position it looks through the whole remaining list, remembering where the smallest value is, then swaps it into place. At most one swap per position.

Card 4676.4.3comparison
Question

How do the two sorts compare on efficiency?

Answer

Both make O(n²) comparisons. Bubble sort makes up to O(n²) swaps; selection sort makes only O(n). Bubble sort has a best case of O(n) on sorted data thanks to its early exit, while selection sort has none.

Card 4686.4.3concept
Question

What is the space complexity of bubble and selection sort?

Answer

Both are O(1). Each sorts in place, needing only a couple of extra variables however large the list becomes.

Card 4696.4.3concept
Question

When is selection sort the better choice?

Answer

When writing data is far more expensive than reading it. The comparison counts are identical, so the algorithm doing O(n) swaps instead of O(n²) is clearly better.

Card 4706.4.4definition
Question

What are the two parts of a recursive function?

Answer

A **base case** that returns without recursing, and a **recursive case** that calls itself on a smaller problem.

Card 4716.4.4concept
Question

Why does deep recursion cause a stack overflow?

Answer

Each call keeps a **stack frame** — parameters, locals, return address — and none is released until the base case is reached.

Card 4726.4.4concept
Question

Why do recursive calls need a stack?

Answer

They return in the **reverse order** they were made, most recent first — last in, first out.

Card 4736.4.4comparison
Question

When is recursion genuinely better than iteration?

Answer

When the **data is self-similar** — a tree, a folder structure, a nested expression. Iterating those needs an explicit stack managed by hand.

Card 4746.4.4concept
Question

Is recursive factorial a good choice?

Answer

It is a good **teaching example**, not a good choice — a loop is faster and uses constant memory.

Card 4756.4.5process
Question

What are the two halves of a recursive trace?

Answer

**Down** — each call is made and waits, with no arithmetic. **Up** — each returns a value, and the arithmetic happens.

Card 4766.4.5concept
Question

When does the arithmetic in n + recurse(n-1) happen?

Answer

On the way **up**, once the base case has returned a value to add to. Nothing is computed descending.

Card 4776.4.5process
Question

How should a recursive trace be laid out?

Answer

Indent each call **one level further** than its caller; leave the return blank going down and fill it in coming back up.

Card 4786.4.5concept
Question

What changes with two recursive calls per level?

Answer

The calls form a **tree**, the left branch completes before the right, and the same values are computed repeatedly.

Card 4796.4.5concept
Question

Why is naive Fibonacci slow?

Answer

Calls grow **exponentially** — fib(30) makes over 1.3 million — because nothing is remembered between branches and sub-results are recomputed.

Card 4806.5.1definition
Question

What are the three file modes and what does each do?

Answer

r reads and fails if the file does not exist. w empties the file immediately and then writes, creating it if absent. a appends at the end, keeping what was already there.

Card 4816.5.1concept
Question

What is the danger of opening a file in w mode?

Answer

It empties the file the moment it opens, before anything is written. Choosing w when you meant a destroys the previous contents, and no error is raised because it is a valid operation.

Card 4826.5.1process
Question

Why must a line read from a file be stripped and converted?

Answer

Every line carries the invisible newline that ended it, so comparisons fail until it is stripped. And everything read is text, so "72" must be converted with int() before any arithmetic.

Card 4836.5.1concept
Question

Why must a file be closed?

Answer

Its contents may not be fully written to disk otherwise, and an open file holds a system resource, possibly locking it against other programs.

Card 4846.5.1definition
Question

What does a with block do for file handling?

Answer

It closes the file automatically when the block ends, even if something fails inside it. It is the finally block of exception handling, built into the language.

Card 4857.1.1definition
Question

What is object-oriented programming?

Answer

An approach that keeps a thing's data and the operations on it in one place. A book's title and its borrow() method live together, rather than the data in one structure and the code elsewhere.

Card 4867.1.1comparison
Question

What is the difference between a class and an object?

Answer

A class is the template, saying what every one of this kind will have and can do; it holds no values itself. An object is one actual thing made from that class, with its own values.

Card 4877.1.1comparison
Question

What is the difference between inheritance and polymorphism?

Answer

Inheritance is reusing what a more general class already has — Ebook takes Book's title and author. Polymorphism is the same method call answered appropriately by each kind. Inheritance often makes polymorphism possible, but they are different ideas.

Card 4887.1.1concept
Question

Give two advantages and two disadvantages of OOP.

Answer

Advantages: it models real things with data and behaviour, and inheritance gives reuse with no copied code. Disadvantages: the class structure must be designed before coding, and it is more code than a small task needs.

Card 4897.1.1concept
Question

When is OOP not worth using?

Answer

For a short script with no real entities to model — reading a file and printing a total gains nothing from classes while still paying the design and code overhead.

Card 4907.1.2process
Question

How do you find the classes and methods in a description?

Answer

Underline the nouns as candidates for classes and attributes, and the verbs as candidates for methods. It is crude but gets a first draft right surprisingly often.

Card 4917.1.2definition
Question

What are the three parts of a UML class box?

Answer

The name at the top, the attributes in the middle with their types, and the methods at the bottom with their return types — always in that order.

Card 4927.1.2definition
Question

What do -, + and underlining mean in UML?

Answer

A minus sign means private, reachable only inside the class. A plus sign means public. An underlined entry is static, belonging to the class itself rather than to each object.

Card 4937.1.2concept
Question

Where should a method be placed?

Answer

In the class that holds the data it uses. borrow() belongs on Book because Book holds onLoan; putting it elsewhere would force that attribute to be made public, losing encapsulation.

Card 4947.1.2concept
Question

When is inheritance the wrong choice?

Answer

When the relationship is really 'has a' rather than 'is a'. A Library has Books but is not a Book, so it should hold a collection rather than inherit.

Card 4957.1.3comparison
Question

What is the difference between a static and a non-static variable?

Answer

A non-static (instance) variable has one copy per object, holding what makes that object different. A static (class) variable has exactly one copy belonging to the class itself, shared by every object.

Card 4967.1.3concept
Question

Why must a counter of objects created be static?

Answer

Because it is a fact about the class, not about any one object. As an instance variable, every object would hold its own count of 1 rather than a shared running total.

Card 4977.1.3comparison
Question

What is the difference between a static and an instance method?

Answer

An instance method uses the object's own data and cannot be called without an object. A static method belongs to the class, uses no object's data, and can be called as Book.count() with no object at all.

Card 4987.1.3concept
Question

Why can a static method not use instance variables?

Answer

It can be called with no object in existence, so there is nothing for self to refer to — no way to know which object's data was meant.

Card 4997.1.3process
Question

What test decides between static and instance?

Answer

Would every object have the same value, always? Yes means static; no means it must be an instance variable. In doubt, choose instance — sharing one value is a decision, not a default.

Card 5007.1.4comparison
Question

What is the difference between defining a class and instantiating an object?

Answer

Defining writes the template once, saying what every one will have and can do. Instantiating creates an actual object from that template, with its own values, as often as needed.

Card 5017.1.4definition
Question

What does a constructor do?

Answer

It runs automatically when an object is created and gives every attribute a value, so no object ever exists in an unfinished state. It can also refuse invalid values before the object exists.

Card 5027.1.4definition
Question

What does self refer to?

Answer

The object the method was called on. self.title is this particular book's title, which is what lets one method definition serve every object of the class.

Card 5037.1.4concept
Question

Why is not every attribute a constructor parameter?

Answer

Some have a single correct starting value. A new book is never on loan, so onLoan is set to False inside the constructor rather than asked for — which removes a chance to get it wrong.

Card 5047.1.4concept
Question

What happens if a constructor misses an attribute?

Answer

The object exists with a missing value, and the failure appears much later, somewhere that has nothing to do with the cause — which makes it hard to trace.

Card 5057.1.5definition
Question

What is encapsulation?

Answer

Keeping an object's data private and providing public methods as the only way to reach it, so every change goes through code that can check it first rather than any part of the program writing whatever it likes.

Card 5067.1.5comparison
Question

What is the difference between encapsulation and information hiding?

Answer

Encapsulation is the mechanism — private attributes, public methods. Information hiding is the principle behind it: the outside should know what a class does, not how, so the inside can be rewritten without breaking callers.

Card 5077.1.5definition
Question

What are getters and setters?

Answer

A getter returns a private value; a setter changes one after checking it. Providing a getter but no setter makes a value readable from outside but not changeable.

Card 5087.1.5concept
Question

Why is a setter with no checks not really encapsulation?

Answer

The data is then effectively public with extra typing. The value of encapsulation lies in the checking that happens on the way in, not in the wrapping itself.

Card 5097.1.5concept
Question

How does a private attribute help when a value is wrong?

Answer

The fault must be inside that class, since nothing outside could have written it. With a public attribute, any line of the whole program could be responsible — the same argument as preferring local variables to global ones.

Card 5107.2.1definition
Question

What is inheritance?

Answer

Defining a class as a **specialised version** of another, taking its attributes and methods and adding its own.

Card 5117.2.1concept
Question

Inheritance or composition — how do you choose?

Answer

Say it aloud. "A SavingsAccount **is an** Account" → inheritance. "A Car **has an** Engine" → composition.

Card 5127.2.1process
Question

What does super() do?

Answer

Calls the **parent's** version — usually the constructor, which sets the inherited attributes. Without it those attributes are never set.

Card 5137.2.1definition
Question

What is overriding?

Answer

A child class **redefining** a parent's method. Its version is used for objects of that class only.

Card 5147.2.1concept
Question

Why is inheritance the tightest coupling in OOP?

Answer

A child depends on the parent's **internals**, not just its interface, so one change to the parent can break every subclass at once.

Card 5157.2.2definition
Question

What is polymorphism?

Answer

The **same call** behaving differently depending on the object it is made on — the caller never asks what type it holds.

Card 5167.2.2comparison
Question

Overriding or overloading: same name, different parameters, one class?

Answer

**Overloading** — resolved at compile time. Overriding is a child replacing a parent's method, resolved at run time.

Card 5177.2.2concept
Question

What does polymorphism replace?

Answer

A type-checking **if-chain**, repeated everywhere the objects are handled — and every copy is a place to forget a type.

Card 5187.2.2example
Question

What does adding a new subclass cost in polymorphic code?

Answer

**Nothing** — it works with existing loops immediately, so no working code is edited and nothing can break.

Card 5197.2.2concept
Question

Is inheritance the same as polymorphism?

Answer

No. Inheritance **shares** a method; polymorphism is the same call **resolving differently** per object. Inheritance is usually how it is achieved.

Card 5207.2.3definition
Question

What is abstraction?

Answer

Exposing only the operations a caller needs and **hiding how they are done**.

Card 5217.2.3comparison
Question

Abstraction or encapsulation?

Answer

**Abstraction** decides *what* is exposed (design). **Encapsulation** enforces *how* it is protected (access control).

Card 5227.2.3concept
Question

Why can an abstract class not be instantiated?

Answer

Its abstract methods have **no bodies**, so an object of it could be asked to run a method that does not exist.

Card 5237.2.3comparison
Question

Abstract class or interface — when do you use each?

Answer

**Abstract class** when children share real behaviour and attributes. **Interface** when unrelated classes must offer the same operations.

Card 5247.2.3example
Question

What is a leaky abstraction?

Answer

One where the caller must know **how** it works to use it correctly — saveToMySQL() rather than save().

Card 5257.2.4comparison
Question

Composition or aggregation — what is the difference?

Answer

Both are has-a. **Composition** owns the part, which dies with the whole. **Aggregation** references a part that exists independently.

Card 5267.2.4process
Question

What is the survival test?

Answer

Delete the whole. If the part still makes sense it is **aggregation**; if it is meaningless it is **composition**.

Card 5277.2.4example
Question

What is the tell in code?

Answer

The whole **creating** the part inside itself → composition. The part **passed in** → aggregation.

Card 5287.2.4definition
Question

Which UML diamond means composition?

Answer

The **filled** diamond ◆. A hollow diamond ◇ means aggregation.

Card 5297.2.4concept
Question

Why prefer composition over inheritance?

Answer

Looser coupling (interface, not internals), parts swappable at run time, and none of the parent's unwanted members.

Card 5307.2.5definition
Question

What is a design pattern?

Answer

A **named, reusable solution** to a recurring problem — a description of a structure and why it works, not a library.

Card 5317.2.5definition
Question

What does the observer pattern do?

Answer

Objects **subscribe** to a subject and are notified when it changes. The subject never knows who is listening.

Card 5327.2.5definition
Question

What is the factory pattern for?

Answer

Putting the decision of **which subclass to create** in one place, so concrete class names are not scattered through the code.

Card 5337.2.5definition
Question

What is the strategy pattern?

Answer

Interchangeable algorithms behind one interface, **selected at run time** — replacing an if-chain that chooses behaviour.

Card 5347.2.5concept
Question

Why is singleton criticised?

Answer

It is **global state**: testing becomes hard and the parts of the program that depend on it are hidden.

Card 5358.1.1definition
Question

What does an abstract data type define?

Answer

The **operations** available and what they mean — not how the data is stored.

Card 5368.1.1concept
Question

ADT or data structure: a stack?

Answer

**ADT.** It promises push, pop, peek and last-in-first-out order. An array or a linked list is how you build one.

Card 5378.1.1concept
Question

Why hide an ADT's implementation?

Answer

So it can be **replaced** without changing any calling code, because callers only ever depended on the operations.

Card 5388.1.1definition
Question

Which ADT enforces uniqueness?

Answer

A **set** — duplicates cannot be stored, so the structure guarantees it rather than the programmer remembering to check.

Card 5398.1.1example
Question

How should an ADT choice be justified in an exam?

Answer

By the operation the program performs **most**, with its complexity — and what the alternative would cost.

Card 5408.1.2definition
Question

What does each node in a singly linked list hold?

Answer

A **value** and a **reference to the next node**. Nothing else, and no node needs to sit beside another in memory.

Card 5418.1.2concept
Question

Why is reaching the nth element of a linked list O(n)?

Answer

There is no calculation that locates a node — you must start at the head and **follow every reference** in turn.

Card 5428.1.2comparison
Question

Singly, doubly, circular — what is the difference?

Answer

**Singly** points forwards only. **Doubly** points both ways, at the cost of a second reference per node. **Circular** links the last node back to the first, so there is no null end.

Card 5438.1.2concept
Question

What is the linked-list trade-off?

Answer

It gives up **direct access** (O(n) to reach position n) and gains **cheap insertion and deletion** (O(1) once in position), plus a size that grows and shrinks.

Card 5448.1.2example
Question

Why can an array beat a linked list even when complexity says otherwise?

Answer

Array elements are **contiguous**, so reading one pulls its neighbours into cache. Linked-list nodes are scattered, so each hop risks a cache miss.

Card 5458.1.3definition
Question

What two things define a linked list?

Answer

A **Node** holding a value and a reference to the next, and a **head** reference pointing at the first node.

Card 5468.1.3process
Question

In what order are the two references assigned when inserting?

Answer

**Point the new node forwards first** (new.next ← prev.next), then repoint the previous node (prev.next ← new). The other order overwrites the only reference to the rest of the list.

Card 5478.1.3process
Question

How is a node deleted from a singly linked list?

Answer

By **routing around it**: prev.next ← target.next. Nothing is erased — the node simply becomes unreachable.

Card 5488.1.3concept
Question

Why is deleting the head a special case?

Answer

There is no previous node to reroute, so the head itself moves: head = head.next.

Card 5498.1.3process
Question

How does a traversal of a circular list stop?

Answer

When current returns to the **head**. There is no None to test for.

Card 5508.1.4definition
Question

What is the binary search tree ordering rule?

Answer

For **every** node, all values in its left subtree are smaller and all in its right subtree are larger — every descendant, not just the children.

Card 5518.1.4concept
Question

Why is a BST search fast?

Answer

Each comparison says which side the value must be on, so an **entire subtree** is discarded without being examined. About log₂ n comparisons when balanced.

Card 5528.1.4process
Question

What does an in-order traversal give you?

Answer

Every value in **ascending order** — left subtree, node, right subtree — with no sorting step.

Card 5538.1.4concept
Question

What does sorted input do to a BST?

Answer

Every value goes the same direction, so the tree **degenerates into a line**: height n, search O(n), exactly like a linked list.

Card 5548.1.4process
Question

How is a node with two children deleted?

Answer

It is replaced by its **in-order successor** — the smallest value in its right subtree — which preserves the ordering rule.

Card 5558.1.5definition
Question

What two guarantees does a set make?

Answer

**No duplicates** and **no order** — both enforced by the structure rather than by the programmer.

Card 5568.1.5definition
Question

Union, intersection, difference — what are they?

Answer

**Union** everything in either · **intersection** only what is in both · **difference** in the first and not the second.

Card 5578.1.5concept
Question

Is a − b the same as b − a?

Answer

**No.** With a = {1,2,3} and b = {3,4}: a − b = {1,2} but b − a = {4}. Difference is the one operation whose order matters.

Card 5588.1.5concept
Question

Why is set membership O(1) on average?

Answer

The value itself computes where it would be stored, so nothing is searched for. A list must compare against every element — O(n).

Card 5598.1.5example
Question

When is a set the wrong choice?

Answer

When the program needs **position or order** — a set has neither, and no index to ask with.

Card 5608.1.6process
Question

How does a hash table locate a value?

Answer

It runs the key through a **hash function**, takes the result **modulo the table size**, and goes straight to that bucket. The address is computed, not searched for.

Card 5618.1.6definition
Question

What three properties must a hash function have?

Answer

**Deterministic** (same key, same bucket, always), **fast** (it runs on every operation) and **uniform** (keys spread evenly).

Card 5628.1.6concept
Question

Why are collisions inevitable?

Answer

There are more possible keys than buckets, so two keys must eventually map to the same one. It is a counting argument, not a defect.

Card 5638.1.6comparison
Question

Chaining or open addressing — what is the difference?

Answer

**Chaining** stores colliding keys in a list inside the bucket. **Open addressing** puts them in the next free bucket, so the table can never hold more items than buckets.

Card 5648.1.6concept
Question

What is a hash table's complexity?

Answer

**O(1) on average, O(n) in the worst case** — the worst case being a hash function that clusters every key into one bucket.

Track your progress with spaced repetition

Sign up free to get personalised review schedules and see exactly which cards you need to practice most.

Get Started Free