Q11011₂ in decimal is:
- A9
- B11
- C13
- D23
Show answer
Correct answer: B — 11
Place values 8, 4, 2, 1: 8 + 0 + 2 + 1 = 11.
122 multiple-choice questions and 92 exam-style questions with mark schemes, organised by chapter, with answers you can check as you go. Free, no sign-up.
New to a topic? Read the CS Fundamentals notes first, then come back to practise.
Q11011₂ in decimal is:
Correct answer: B — 11
Place values 8, 4, 2, 1: 8 + 0 + 2 + 1 = 11.
Q2How many values can 6 bits represent?
Correct answer: C — 64
Each extra bit doubles the number of possibilities, so n bits give 2ⁿ values: 2⁶ = 64. Those values run from 0 to 63, not 1 to 64 — the count includes zero, which is why the largest value is always one less than the total.
Q3FF₁₆ in decimal is:
Correct answer: B — 255
F is 15, so FF = 15×16 + 15 = 255. It is also 11111111 in binary, the largest 8-bit value.
Q410110110₂ in hexadecimal is:
Correct answer: A — B6
Group in fours from the right: 1011 = B and 0110 = 6, giving B6. Grouping from the left instead is the usual error.
Q5Decimal 13 in binary is:
Correct answer: B — 1101
Dividing by 2 repeatedly gives remainders 1, 0, 1, 1 read upwards as 1101. Check: 8 + 4 + 1 = 13.
Q6ASCII uses 7 bits, so it can represent:
Correct answer: C — 128 characters
2⁷ = 128. Option D would be 8-bit extended ASCII, which is a different code.
Q7Adding 11111111 and 00000001 in 8 bits produces:
Correct answer: B — 00000000 with overflow
255 + 1 = 256, which needs 9 bits. The carry out of the last column is lost, leaving 00000000 stored — a wrong answer, which is exactly what overflow means.
Q8Why is hexadecimal preferred to binary for writing memory addresses?
Correct answer: B — it is four times shorter and converts with no arithmetic
Each hex digit replaces exactly four bits, so a 32-bit address becomes 8 characters. The machine still stores binary — hex is purely for human readability.
Q9A colour depth of 4 bits allows how many colours?
Correct answer: C — 16
2⁴ = 16. The depth is a count of bits, and the number of colours is 2 raised to it.
Q10ASCII uses 7 bits, representing:
Correct answer: C — 128 characters
2⁷ = 128. Extended ASCII adds an eighth bit to reach 256.
Q11The file size of a bitmap depends on:
Correct answer: C — both resolution and colour depth
Size = width × height × colour depth. An image using only two colours still stores the full depth for every pixel unless it is compressed.
Q12A 500 × 400 image at 8 bits per pixel occupies:
Correct answer: C — 200 000 bytes
500 × 400 × 8 = 1 600 000 bits, and dividing by 8 gives 200 000 bytes. Option B is the answer before converting to bytes.
Q13Increasing the sample rate of a recording:
Correct answer: B — improves accuracy and increases the file size
More measurements per second follow the wave more closely and take proportionally more storage.
Q14Sample resolution refers to:
Correct answer: B — how many bits store each measurement
How often is the sample RATE. Resolution is the precision of each individual measurement.
Q15Recording in stereo rather than mono:
Correct answer: B — doubles the file size
Two independent channels are stored, so everything is duplicated.
Q16The first 128 Unicode code points are identical to ASCII because:
Correct answer: B — it keeps existing ASCII text readable
Backwards compatibility: any file written in ASCII is already valid Unicode, so no conversion was needed for the vast amount of text that already existed.
A computer is built from electronic switches, each of which has only two reliable states — on and off, or high and low voltage. Binary has exactly two digits, so each digit maps directly onto one switch, making the hardware simple and resistant to electrical noise.
11010₂ to decimal.Place values 16, 8, 4, 2, 1: 16 + 8 + 0 + 2 + 0 = 26.
It is far shorter and easier to read — one hex digit replaces four bits, so a 32-bit address takes 8 hex characters instead of 32 binary ones — while converting between the two needs no arithmetic at all.
2C₁₆ to binary and then to decimal.2 in hex is 0010 in binaryfour bits per hex digit[1]C is 12 in decimal, which is 1100A=10, B=11, C=12, D=13, E=14, F=15[1]00101100₂concatenate the groups, do not add them[1]32 + 8 + 4 = 44or 2×16 + 12 = 44 directly from hex[1]2C₁₆ = 00101100₂ = 44₁₀
11001010 and 01110011. State whether overflow occurs.01000010 with a carry out of the leftmost column[1]202 + 115 = 317, which exceeds the 8-bit maximum of 255[1]Carry out of the final column; overflow occurs because 317 > 255.
2⁷ = 128 characters[1]2²⁴ = 16 777 216 coloursaccept "about 16.7 million"[1]= 100 × 200 = 20 000[1]20 000 × 3 = 60 000 bytesconverting bits to bytes is the step most often missed[1]60 000 / 1024 = 58.6 KBaccept 58.6 or 60 KB if 1000 bytes per KB is stated[1](a) 128, too few for a second script (b) 16 777 216 (c) about 58.6 KB
Advantage: it represents over a million characters, covering every writing system including Urdu and Chinese, where ASCII covers only 128. Disadvantage: each character may need up to four bytes rather than one, so files are larger.
2⁸ = 256 colours.
Sample rate is the number of measurements taken per second, in hertz. Sample resolution is the number of bits used to store each measurement. The first controls accuracy in time, the second accuracy in amplitude.
= 1024 × 768 = 786 432[1]= 786 432 × 16 = 12 582 912[1]= 12 582 912 ÷ 8 = 1 572 864dividing by 8 is the step most often missed[1]= 1 572 864 ÷ 1024 = 1536 KB[1]1536 KB (1.5 MB)
= 44 100 × 16 × 30rate × resolution × seconds[1]= 21 168 000 bits[1]= 2 646 000, so ÷ 1 048 576 = 2.52 MBaccept 2.65 MB using 1 000 000[1]About 2.5 MB mono, doubling to about 5 MB in stereo
(a) fewer pixels or fewer bits per pixel (b) size is proportional to depth, and 24 is 3 × 8 (c) sorting and case conversion become arithmetic
Q1A two-input AND gate outputs 1 when the inputs are:
Correct answer: D — 1 and 1
AND requires every input to be 1. Any 0 forces the output to 0.
Q2A NOR gate outputs 1 when:
Correct answer: B — both inputs are 0
NOR is OR followed by NOT. OR gives 0 only when both inputs are 0, so NOR gives 1 only then.
Q3The expression (A + B)′ is equivalent to:
Correct answer: B — A′ · B′
De Morgan's second law: complementing a sum turns it into a product of complements. Option A applies the law in the wrong direction.
Q4A truth table for a circuit with 4 inputs has how many rows?
Correct answer: C — 16
2⁴ = 16. Each additional input doubles the number of combinations.
Q5Simplify A·B + A·B′.
Correct answer: A — A
Factor out A to get A·(B + B′), and B + B′ = 1, leaving A · 1 = A. The value of B turns out not to matter at all.
Q6In a half adder, the Carry output is produced by:
Correct answer: B — an AND gate
A carry occurs only when both bits are 1, which is exactly the AND condition. XOR produces the Sum.
Q7Which is TRUE in Boolean algebra?
Correct answer: B — A + 1 = 1
Once one input to an OR is 1 the output is 1 regardless of the other. There is no 2 and no squaring in Boolean algebra, and A + A′ = 1, not 0.
Q8NAND is described as a universal gate because:
Correct answer: B — any logic circuit can be built from NAND gates alone
NOT, AND and OR can all be constructed from NAND gates, and therefore so can anything else. It means a manufacturer can build a whole chip from one repeated gate design.
Q9In Boolean algebra, A + A equals:
Correct answer: B — A
The idempotent law. Variables hold only 0 or 1, so there is nothing to accumulate — unlike ordinary algebra.
Q10(A · B)‾ is equivalent to:
Correct answer: B — Ā + B̄
De Morgan: break the bar and change the AND to an OR.
Q11Karnaugh map headings use Gray code so that adjacent cells:
Correct answer: B — differ in exactly one variable
Single-variable adjacency is what allows a variable to be eliminated when cells are grouped.
Q12A valid Karnaugh map group may contain:
Correct answer: B — only powers of two
Groups must be 1, 2, 4, 8 … cells and rectangular. A group of three cannot eliminate a variable cleanly.
Q13A group of 4 cells on a K-map eliminates how many variables?
Correct answer: B — 2
Each doubling of the group size removes one more variable, so 4 cells remove two.
Q14The four corner cells of a 4×4 Karnaugh map:
Correct answer: B — form a valid group of 4
The map wraps in both directions, so the corners are all adjacent to one another.
Q15A + Ā·B simplifies to:
Correct answer: C — A + B
Expanding gives (A + Ā)(A + B) = 1·(A + B) = A + B.
Q16NAND is functionally complete, which means:
Correct answer: B — any circuit can be built from NAND gates alone
NOT, AND and OR can all be constructed from NAND gates, so anything at all can be. NOR shares this property.
Inputs 00 → 1, 01 → 1, 10 → 1, 11 → 0. NAND is the inverse of AND, so it outputs 0 only when both inputs are 1.
(A · B)′ = A′ + B′ and (A + B)′ = A′ · B′. Complementing a whole expression swaps AND for OR and complements each variable.
Because any logic function whatsoever can be built using copies of just one of them. NOT, AND, OR and every larger circuit can be constructed from NAND alone, or from NOR alone, which is why chip manufacturers can make a whole processor from one repeated gate design.
X = A′ · B + A · B′ and state which single gate it is equivalent to.The table matches XOR: output 1 when A and B differ.
X = (A + B) · (A + B′) using Boolean laws, naming each law you use.A·A + A·B′ + B·A + B·B′distributive law[1]A·A = A (idempotent) and B·B′ = 0 (complement)[1]X = A + A·B′ + A·Bthe zero term disappears[1]A + A·anything = A, so X = Anaming the law is required by the question[1]X = A
(b) XOR for Sum, AND for Carry (c) it has no carry-in input, so a full adder is required
(A · B)‾ = Ā + B̄ and (A + B)‾ = Ā · B̄. In words: break the bar and change the operation between the terms.
This is Gray code order, in which adjacent headings differ in exactly one variable. That adjacency is what makes grouping valid: within a group only one variable changes, so it can be eliminated. With ordinary binary order, neighbouring cells would differ in two variables and grouping would not simplify correctly.
Groups must contain a number of cells that is a power of two (1, 2, 4, 8…); groups must be rectangular and as large as possible; groups may overlap, and the map wraps round so opposite edges are adjacent.
(a) A; (b) A + B; (c) any circuit from one gate type; NAND(A,A) = NOT A
A simpler expression needs fewer gates, which makes the circuit cheaper to manufacture, smaller, and lower in power consumption. Fewer gates in a signal path also means less propagation delay, so the circuit runs faster.
Q1Which of these is volatile?
Correct answer: C — RAM
RAM loses its contents the moment power is removed. The other three are all secondary storage and keep data without power.
Q2The part of the CPU that performs calculations is the:
Correct answer: B — ALU
The arithmetic and logic unit does the arithmetic and the comparisons. The control unit directs traffic but computes nothing itself.
Q3During which stage is the instruction brought from memory into the CPU?
Correct answer: A — Fetch
Fetch places the program counter's address on the address bus and the instruction returns on the data bus.
Q4The address bus is unidirectional because:
Correct answer: B — memory never sends addresses to the CPU
The CPU always decides which location to access, so addresses only ever travel outward. Data, by contrast, must travel both ways.
Q5A computer with 4 GB of RAM slows badly when many programs are open because:
Correct answer: B — it swaps data to much slower storage
When RAM is full the operating system moves pages out to disk. Disk is thousands of times slower than RAM, so every swap costs a long wait.
Q6Which is fastest?
Correct answer: C — Registers
Registers sit inside the CPU itself, so access takes a single clock cycle. The order of the hierarchy is registers, cache, RAM, SSD, hard disk.
Q7A quad-core 2 GHz processor compared with a single-core 3 GHz one:
Correct answer: B — can execute four instruction streams at once
Four cores work simultaneously, so for anything that can be split across them the quad-core wins despite the lower clock speed. Clock speed alone is a poor comparison.
Q8The instruction register holds:
Correct answer: B — the instruction currently being decoded
The address of the next instruction is in the program counter, and the ALU result goes to the accumulator. The instruction register holds only the one being worked on now.
Q9In the von Neumann architecture, programs and data are:
Correct answer: B — stored in the same memory
Sharing one memory is the defining feature, and it is what allows a machine to be reprogrammed by loading different data.
Q10The program counter holds:
Correct answer: B — the address of the next instruction
It holds an address, not an instruction — and the address of the next one, which is why it can be incremented early.
Q11During the fetch stage, the instruction is copied from the MDR into the:
Correct answer: C — CIR
The current instruction register holds the instruction while the control unit decodes it.
Q12The address bus is unidirectional because:
Correct answer: B — only the processor generates addresses
Memory never sends an address back to the processor, so there is no need for the bus to run both ways.
Q13The von Neumann bottleneck arises because:
Correct answer: B — instructions and data share one bus
Sharing a single bus means instruction fetches and data transfers cannot happen simultaneously.
Q14A single-threaded program on a quad-core processor runs:
Correct answer: B — at about the same speed
Extra cores only help when the software divides its work between them. A single thread uses one core.
Q15A graphics processor applying the same operation to millions of pixels is an example of:
Correct answer: B — SIMD
One instruction is applied to many data items simultaneously — Single Instruction, Multiple Data.
Q16A disadvantage of running software in a virtual machine is:
Correct answer: B — reduced performance from the extra layer
Isolation and easy backup are advantages. The cost is that everything passes through an additional software layer.
Q17The always-resident core of an operating system is called the:
Correct answer: B — kernel
The kernel manages the CPU, memory and devices and stays in memory throughout. The shell is the user interface and can be replaced.
Q18Twenty programs appear to run at once on one core because the OS:
Correct answer: B — switches between them very quickly
Time-slicing gives each a few milliseconds in turn. Only one instruction actually executes at any moment.
Q19A slow machine with constant disk activity most likely indicates:
Correct answer: B — RAM is full and the OS is paging
The disk is busy because memory pages are being written out and read back. If the CPU were the bottleneck the processor, not the disk, would be saturated.
Q20Which operating system type guarantees a maximum response time?
Correct answer: B — Real-time
A real-time OS is used where a late response is as dangerous as a wrong one — patient monitors, vehicle control, industrial machinery.
Q21File permissions typically control:
Correct answer: B — read, write and execute rights
Each is granted separately to the owner, a group and everyone else, which is how a system lets some users read a file while preventing them from changing it.
Q22Emptying the recycle bin means the data is:
Correct answer: B — still on the disk until overwritten
Only the index entry is removed. Recovery software can retrieve the contents, which is why a disk being sold must be securely wiped.
Q23Virtual memory addressing allows the OS to:
Correct answer: B — give each program a private address space mapped onto real RAM
Programs are written without knowing where they will sit in memory, and the mapping is what prevents one program from reading another's data.
Q24Adding RAM helps a heavily paging machine more than a faster SSD because it:
Correct answer: A — removes the need to page at all
A faster disk shortens each swap; more RAM means the swap never has to happen. Removing the cause beats reducing the symptom.
RAM is volatile, fast and comparatively small; it holds the programs and data currently in use and loses everything when the power goes. Secondary storage such as an SSD is non-volatile, slower and much larger; it keeps data permanently.
The control unit, which fetches and decodes instructions and sends control signals to the rest of the system; and the arithmetic and logic unit, which performs calculations and logical comparisons.
It holds the address of the next instruction to be fetched. It increments during the fetch stage so that the following cycle picks up the next instruction rather than repeating the current one.
Fetch, decode, execute, store — repeated for every instruction.
Address = where (one-way), data = what (two-way), control = read or write.
(a) Laptop B — more cores, far more RAM, and an SSD (b) twice the storage capacity (c) clock speed ignores cores, cache and RAM
In the von Neumann architecture, program instructions and data are held in the same memory and travel over the same bus. The limitation is the von Neumann bottleneck: instructions and data cannot be transferred simultaneously, so the processor is often left waiting for memory.
The address in the PC is copied to the MAR. The PC is then incremented. The contents of the memory location addressed by the MAR are read into the MDR, and from there the instruction is copied into the CIR ready for decoding.
A jump instruction writes a new address into the PC during execution. If the increment happened afterwards, that new address would be increased by one and the jump would land at the wrong instruction. Incrementing during the fetch means a jump can simply overwrite the PC and execution continues correctly.
(a) address one-way, data two-way; (b) fewer slow memory accesses; (c) single-threaded; (d) isolation vs overhead
SIMD applies a single instruction to multiple data items at the same time — used by graphics processors operating on many pixels identically. MIMD executes different instructions on different data simultaneously — used by multi-core processors running separate tasks.
The core of the OS, permanently resident in memory, which manages the CPU, memory and devices and controls access to them. Other parts of the OS such as the user interface can be restarted or replaced; the kernel cannot.
Through time-slicing: the operating system gives each program a few milliseconds of CPU time in turn and switches between them far faster than a person can perceive. Only one instruction is ever executing, so the simultaneity is an illusion.
Any program that runs inherits the permissions of the account that started it. Malware launched from an administrator account can therefore alter system files and install itself permanently, whereas the same malware run from a standard account is confined to that user's own files.
Process, memory, file and device management — plus security and the user interface.
RAM is full and the OS is paging to disk. Close programs, or add RAM.
(a) multi-tasking for the office, real-time for the monitor (b) a guaranteed maximum response time (c) separate read and write rights per group
Q1Breaking a large problem into smaller parts is called:
Correct answer: B — decomposition
Decomposition splits the problem up. Abstraction is a different habit — removing irrelevant detail from whatever you are looking at.
Q2Which flowchart symbol has two exits?
Correct answer: C — Diamond
The decision diamond asks a yes/no question, so exactly two branches leave it and both must be labelled.
Q3An algorithm must be finite, meaning it:
Correct answer: B — always stops
Finiteness is about termination. An algorithm may have thousands of steps and still be finite, provided it eventually stops.
Q4A metro map omitting real distances is an example of:
Correct answer: B — abstraction
Irrelevant detail — actual geography — has been removed so the useful information, the order of stations and the connections, stands out.
Q5For a rule "age must be 18 to 65", boundary test data would include:
Correct answer: B — 18 and 65
Boundary data sits exactly at the limits. Option A is normal data and option C is erroneous data — all three types should be tested, but only B is boundary.
Q6In a flowchart, an arrow without an arrowhead:
Correct answer: B — does not show the direction of flow and loses a mark
The whole purpose of the flow line is to say which way the logic runs. Without a head it says nothing, and examiners mark it as incomplete.
Q7Where should OUTPUT largest be placed when finding the biggest of ten numbers?
Correct answer: B — after the loop
Inside the loop it prints on every pass, giving ten lines. After the loop it runs once, with the final answer — which is what was asked for.
Q8A trace table is used to:
Correct answer: B — follow an algorithm by hand and find logic errors
Recording every variable at every step exposes errors on paper, long before the program is written and at a fraction of the cost.
Q9An algorithm takes 5n + 300 steps. What is its complexity?
Correct answer: B — O(n)
Big-O keeps only the fastest-growing term and drops constant factors. As n grows large, 5n dominates the fixed 300, and the 5 does not change the shape of the curve. What is left is O(n).
Q10Binary search on a sorted array of 1,000,000 items takes roughly how many comparisons?
Correct answer: C — 20
Each comparison halves the search space, so the count is log₂(1,000,000) ≈ 20. That is the practical power of logarithmic growth: a thousand-fold more data costs only about ten extra steps.
Q11Which sort is fastest on data that is already almost sorted?
Correct answer: B — Insertion sort
Insertion sort only shifts elements that are genuinely out of place. On nearly-sorted input almost nothing moves, so it approaches O(n). Selection sort scans the entire remaining array every pass regardless, so it stays O(n²) no matter how ordered the data is.
Q12Quicksort is O(n log n) on average. When does it degrade to O(n²)?
Correct answer: B — When the pivot repeatedly splits the array very unevenly
Quicksort relies on the pivot cutting the array roughly in half. If the pivot is always the smallest or largest element — as happens when you take the last element of an already-sorted array — each partition removes just one item, giving n levels of recursion instead of log n.
Q13Why does O(2ⁿ) become unusable so quickly?
Correct answer: B — Every extra input element doubles the total work
Doubling per element is brutal. Going from n = 50 to n = 51 does not add a step, it adds as much work as all 50 previous elements combined. Exponential algorithms are typically replaced with dynamic programming or approximation.
Q14Two algorithms are O(n). One runs in 2 seconds, the other in 10. What does Big-O say about this?
Correct answer: B — Nothing — Big-O describes growth rate, not absolute speed
Big-O deliberately ignores constant factors. Both will scale the same way — double the input and both roughly double their time — even though one is five times slower throughout. For choosing between two same-class algorithms you need real measurement, not Big-O.
A finite sequence of unambiguous instructions that solves a problem or completes a task, with clearly defined inputs and outputs.
Abstraction is removing the details that are not relevant to the problem being solved, so that the essential structure is easier to work with. A metro map shows the order of the stations and the connections between lines, but omits real distances and street layout — which makes it more useful for planning a journey, not less.
A flowchart is graphical, using standard shapes and arrows, and shows the flow of control visually. Pseudocode is textual, resembles program code and is quicker to write and to translate into a real language. Flowcharts become unwieldy for long algorithms, where pseudocode stays readable.
INPUT mark[1]WHILE mark < 0 OR mark > 100 → OUTPUT "Invalid" and INPUT mark againa loop, not a single if — the user may enter a bad value twice[1]IF mark >= 40 THEN OUTPUT "Pass"the >= is required; > alone fails a mark of exactly 40[1]ELSE OUTPUT "Fail" ENDIF[1]Input with a validation loop, then IF mark >= 40 output Pass ELSE output Fail.
SET total = 0; SET i = 1; WHILE i <= n DO total = total + i; i = i + 1; ENDWHILE; OUTPUT totali = 2, total = 1; after pass 2: i = 3, total = 3[1]i = 4, total = 6; after pass 4: i = 5, total = 10[1]5 > 4; output is 10the algorithm sums 1 to n[1]Output 10 — the algorithm computes 1 + 2 + 3 + 4.
(a) split into recording, storing, calculating and reporting (b) store only roll number and present/absent (c) edges are where errors hide — e.g. exactly 75% attendance
The data must already be sorted. The algorithm discards half the list at each step by comparing with the middle item, which is only valid if the order is known.
A measure of how the number of operations grows as the size of the input grows, written in big-O notation. It describes the trend, not the exact running time on a particular machine.
About 10, because 2¹⁰ = 1024. Each comparison halves the remaining list, so the maximum is log₂ n rounded up.
O(n²)[1]low = 1 and high = 5000[1]low <= high[1]mid = (low + high) DIV 2[1]high = mid − 1 or low = mid + 1 correctly[1]low > high[1]2¹³ = 8192[1]O(n log n).O(n²) as n grows. [2]n log n[1]Q1Why can an array reach element 500 instantly while a linked list cannot?
Correct answer: B — Array elements are contiguous, so the address can be computed arithmetically
Contiguity is the whole trick: address = base + 500 × elementSize, one multiply and one add. A linked list scatters its nodes, so the only way to find node 500 is to follow 500 pointers from the head.
Q2You need to add and remove items constantly at the front of a collection. Which structure fits best?
Correct answer: B — Linked list
Front insertion and deletion on a linked list is O(1) — you only re-point the head. An array would shift every remaining element on each operation, making it O(n) every single time.
Q3A stack is LIFO. Which real situation matches it?
Correct answer: B — Undo history in a text editor
Undo reverses your most recent action first — last in, first out. The other three are FIFO: the first to arrive is the first served, which is a queue.
Q4An in-order traversal of a binary search tree outputs the values in what order?
Correct answer: B — Ascending sorted order
In-order visits left subtree, then node, then right subtree. Because a BST puts every smaller value left and every larger value right, that recursion emits values from smallest to largest. It is effectively a free sort.
Q5Inserting already-sorted data into a plain binary search tree causes what problem?
Correct answer: B — The tree degenerates into a linked list and search becomes O(n)
Each new value is larger than everything before it, so it always goes right. The result is a single chain with no branching, and lookup degrades from O(log n) to O(n). Self-balancing trees exist precisely to prevent this.
Q6Breadth-first search needs which helper structure?
Correct answer: B — A queue
BFS explores level by level, so nodes must come out in the same order they were discovered — FIFO, a queue. Swapping in a stack turns the same algorithm into depth-first search.
Advantage: any element can be reached directly from its index in constant time. Disadvantage: inserting at the front requires every later element to be shifted.
A stack is last-in-first-out: items are added and removed at the same end. A queue is first-in-first-out: items are added at one end and removed from the other.
On a push the pointer is incremented and the new item is written at that position. On a pop the item at the pointer is read and the pointer is decremented. The pointer must be checked against the array bounds first.
(b) 20, 30, 40, 50, 60, 70
Q1SQL is an example of which paradigm?
Correct answer: B — declarative
A query states the result required without describing how to obtain it — the defining feature of declarative programming.
Q2Encapsulation means:
Correct answer: B — bundling data with its methods and restricting access
The data is kept private so every change goes through a method that can validate it.
Q3The same method call producing different behaviour on different object types is:
Correct answer: C — polymorphism
Polymorphism resolves the call according to the actual type of the object receiving it.
Q4A subclass gaining the members of a superclass is:
Correct answer: B — inheritance
Inheritance lets shared behaviour be written once in the superclass and reused by every subclass.
Q5Code that must run whether or not an exception occurred belongs in:
Correct answer: C — FINALLY
FINALLY executes on both paths, which is why resource cleanup such as closing a file belongs there.
Q6Catching all exceptions in one generic handler is poor practice because it:
Correct answer: B — can hide genuine bugs and loses specificity
Different errors deserve different responses, and an unexpected error gets silently swallowed rather than noticed.
Q7Which paradigm would suit writing a device driver?
Correct answer: B — low-level
Direct access to hardware registers and precise timing control are required, which higher-level paradigms deliberately abstract away.
Q8An advantage of exception handling over checking every operation with an if is that:
Correct answer: B — the normal logic stays readable
The error path is separated from the main flow, so the normal logic is not interrupted by a check after every statement.
Q9A recursive routine must always contain:
Correct answer: B — a base case
The base case is what allows the recursion to stop. Without it the calls never end.
Q10A recursive function with no base case will:
Correct answer: B — cause a stack overflow
Every call pushes a frame and none ever returns, so the stack memory is exhausted.
Q11A stack frame stores:
Correct answer: B — the return address, parameters and local variables
It holds everything needed to resume the suspended call once the deeper one returns.
Q12For F(n) = n × F(n−1) with F(1) = 1, calling F(4) pushes how many frames?
Correct answer: C — 4
Frames are pushed for F(4), F(3), F(2) and F(1) — four in total. 24 is the result, not the depth.
Q13During recursion, calculations happen:
Correct answer: B — on the way back up after the base case
Each call is suspended at the recursive call. The work is completed as the frames are popped.
Q14Recursive calls complete in which order?
Correct answer: B — last in, first out
The stack is LIFO, so the most recently pushed frame is the first to be popped and completed.
Q15The main disadvantage of recursion compared with iteration is:
Correct answer: B — it uses more memory for stack frames
Anything recursive can be written iteratively; the cost is one stack frame per level of depth.
Q16Recursion is most naturally suited to:
Correct answer: B — traversing a tree
A tree is itself defined recursively, so a recursive traversal matches the structure. Simple repetition is better served by a loop.
An imperative program specifies how to obtain the result, as an ordered sequence of statements that change the program state. A declarative program specifies what result is required and leaves the method of obtaining it to the system — SQL being the standard example.
Encapsulation means bundling data together with the methods that operate on it inside a class, and making the data private so it can only be accessed through those methods. The benefit is that the data cannot be set to an invalid value by unrelated code, since every change passes through a method that can validate it — so the object stays in a consistent state.
Polymorphism means the same method call behaves differently depending on the object it is applied to. For example, calling Area() on a Circle runs the circle's formula while the same call on a Rectangle runs a different one — the calling code does not need to know which type it holds.
(a) separates normal and error paths; (b) files close either way; (c) loses specificity and hides bugs; (d) readability
Writing a device driver or code for an embedded microcontroller. Direct access to specific registers, memory addresses and hardware timing is required, and the precise number of clock cycles may matter — control a high-level language deliberately abstracts away.
It must have a base case that returns a value without calling itself, and each recursive call must make progress towards that base case — typically by reducing the parameter.
Each call pushes a stack frame containing the return address, the parameters and any local variables, so the suspended call can be resumed. Frames accumulate as the recursion descends. When the base case returns, the frames are popped in reverse order — last in, first out — with each completing its calculation as it goes.
It calls itself indefinitely, pushing a new stack frame each time and never returning. The stack eventually runs out of memory and the program terminates with a stack overflow error.
(a) S(1)=1 and S(n)=n+S(n−1); (b) S(5) = 15; (c) clarity vs stack memory
Recursion is preferable for recursive data structures such as traversing a tree, or for divide-and-conquer algorithms like quicksort, where an iterative version would need an explicit stack of its own. Iteration is preferable for simple repetition such as summing a list, where recursion would waste memory on stack frames for no gain in clarity.
Q1Data is split into packets before transmission mainly because:
Correct answer: B — Lost data can be resent in small pieces and links can be shared
Packet switching means a single lost packet costs one retransmission rather than a whole file, and many conversations can interleave on one link. Packets do not travel faster than anything — the medium sets the speed — and splitting provides no encryption at all.
Q2Which protocol would a live video call most likely use?
Correct answer: B — UDP, because late data is useless anyway
A retransmitted video frame arrives after the moment it belonged to, so TCP's guarantees buy nothing and its waiting causes stalls. UDP tolerates a brief glitch to keep the call live. SMTP is for email.
Q3A MAC address differs from an IP address in that it is:
Correct answer: B — Fixed to the hardware and used only on the local network
The MAC address is burned into the network interface and only has meaning within one local network segment. The IP address is assigned by the network you join and is what routing across the internet uses.
Q4The purpose of DNS is to:
Correct answer: B — Translate domain names into IP addresses
DNS is the internet's phone book, turning a human-readable name into the numeric address routing actually needs. Encryption is TLS, packetising is the transport layer, and route selection is the job of routers running IP.
Q5In the layered model, the main benefit of layers is that:
Correct answer: B — Each layer can be changed without disturbing the others
Layering isolates concerns. Swapping ethernet for wifi replaces the data-link and physical layers entirely, and TCP, IP and your browser never notice. Layers add a little overhead rather than removing any.
Q6TCP establishes a connection using:
Correct answer: B — A three-way handshake: SYN, SYN-ACK, ACK
Three messages confirm that both sides can send and receive before real data flows. The certificate exchange is the separate TLS handshake, which happens after the TCP connection is already up.
Q7The world wide web is:
Correct answer: B — a collection of pages accessed over the internet
The internet is the infrastructure; the web is one kind of content carried on it, alongside email and file transfer.
Q8DNS converts:
Correct answer: B — a domain name into an IP address
The network routes by numeric address, so the memorable name must be looked up first.
Q9A session cookie is deleted:
Correct answer: B — when the browser is closed
It is held in memory for the duration of the visit. A persistent cookie is written to disk and survives until it expires.
Q10A cookie can:
Correct answer: C — store text data for a website
It is a small text file readable only by the site that set it. It cannot execute, so it cannot be malware.
Q11HTTPS differs from HTTP in that it:
Correct answer: B — encrypts the traffic
It is the same protocol with encryption added, secured by a digital certificate that also confirms the site's identity.
Q12The padlock in a browser means:
Correct answer: B — the connection is encrypted and the certificate is valid
It says the connection is secure and the site is who its certificate says. A fraudulent site can obtain a valid certificate.
Q13Which happens FIRST when a URL is entered?
Correct answer: B — a DNS lookup
The browser cannot send a request until it knows the IP address to send it to.
Q14An ISP is:
Correct answer: B — the company providing the internet connection
The internet service provider supplies the physical connection and usually the router and IP address that come with it.
A LAN covers a small geographical area such as one building and its hardware is usually owned by the organisation. A WAN covers a large area and typically uses third-party communication links.
An IP address identifies a device on a network and can change when the device moves to a different network. A MAC address is fixed in the hardware and uniquely identifies the network adapter itself.
The data is divided into equal-sized blocks. Each packet carries a header with the source and destination addresses and its sequence number, and packets may travel by different routes and are reassembled in order at the destination.
The internet is the global infrastructure of interconnected networks that carries data. The world wide web is a collection of pages and resources accessed over that infrastructure — one of several services using it, alongside email and file transfer.
It translates a domain name that people can remember into the IP address the network needs to route data. This also allows a site to move to a different server without its address changing for visitors.
Keeping a user logged in as they move between pages of a site, and remembering preferences such as language, currency or the contents of a shopping basket.
DNS lookup → HTTP request → server response → further resource requests → parse and render.
Encryption in transit plus a certificate proving identity; the padlock says nothing about the site's honesty.
(a) session in memory until the browser closes; persistent on disk until expiry (b) cross-site tracking builds a browsing profile (c) it is data, not a program
Q1In machine learning, the computer produces:
Correct answer: B — the rules
You supply data and answers; the system derives the rules that connect them. That inversion is the whole idea.
Q2Training on photographs labelled "cat" or "dog" is:
Correct answer: B — supervised learning
The labels are the correct answers supplied with the data, which is precisely what makes learning supervised.
Q3Grouping customers into segments nobody defined in advance is:
Correct answer: B — unsupervised
There are no labels; the structure is discovered by the system rather than specified by a person.
Q4A model scoring 99% on training data and 55% on new data is:
Correct answer: B — overfitting
The gap shows it memorised its examples rather than learning the general pattern. A model that generalised would score similarly on both.
Q5Algorithmic bias mainly arises from:
Correct answer: B — patterns present in the training data
The model faithfully reproduces what it was shown. If the historical data recorded unfair decisions, the model learns to make them.
Q6The test set must be:
Correct answer: B — data the model has never seen
Only unseen data measures generalisation. Testing on training data measures memory, which is not what the model is for.
Q7The "black box" problem means a model:
Correct answer: B — cannot explain how it reached a decision
This is tolerable for a film recommendation and unacceptable for a loan refusal, where the person affected is entitled to a reason.
Q8Reinforcement learning improves by:
Correct answer: B — receiving rewards and penalties for its actions
It is told only how well it did, not what it should have done, and improves over very many attempts.
Q9AI is best suited to tasks involving:
Correct answer: B — finding patterns in large amounts of data
That single capability underlies every successful application. The other three are precisely where these systems are weakest.
Q10Using AI to flag scans for a radiologist to review is an example of:
Correct answer: B — triage
The system sorts by likely urgency and the human still decides, so its errors are caught while the speed benefit is kept.
Q11A legitimate transaction blocked by a fraud system is a:
Correct answer: B — false positive
The system positively identified fraud where there was none. A false negative would be real fraud allowed through.
Q12A model trained on data from one country may fail elsewhere because:
Correct answer: B — the population it learned from differs from the one it is used on
A model reproduces patterns from its training data. If the new population differs in ways that matter, those patterns may not hold.
Q13The strongest argument against fully automating a benefits decision is:
Correct answer: B — the applicant could not be told why they were refused
A consequential decision affecting a person requires a reason they can understand and challenge. Speed and consistency do not compensate for its absence.
Q14Deskilling means:
Correct answer: B — a skill is lost because it is always automated
A capability nobody exercises eventually disappears, which matters most at the moment the automated system fails and someone must step in.
Q15Which is a genuine environmental cost of AI?
Correct answer: B — the electricity used to train large models
Training a large model consumes a substantial amount of electricity, which is an increasingly common point in exam answers about drawbacks.
Q16When AI applies the same rule to every applicant, the benefit is:
Correct answer: B — consistency
Human assessors vary between themselves and across a working day. Consistency is a real advantage — though it also means a flawed rule is applied uniformly to everyone.
Artificial intelligence is the broad field of making machines perform tasks that would ordinarily require human intelligence. Machine learning is a subset of AI in which the system learns patterns from data rather than being given explicit rules. All machine learning is AI; not all AI is machine learning.
Learning from data in which each example is labelled with the correct answer. The model learns to reproduce those labels on new data. Example: training on photographs already tagged "cat" or "dog" so the system can classify unseen photographs.
Because a model can score perfectly on data it has effectively memorised, which says nothing about how it will behave on new examples. Only unseen data measures whether it has learned the general pattern — the property that actually matters in use.
Labelled data, unlabelled data, and reward feedback respectively.
The model learns historical unfairness. Audit the data, test outcomes per group, and keep human oversight.
(a) labelled historical records, split into training and test sets (b) it reproduces past under-support as a prediction (c) a prediction is about likelihood, not about the individual, and cannot justify itself
AI can analyse medical images such as chest X-rays and flag those most likely to show disease, so a radiologist reviews the urgent cases first. The benefit is speed and consistency: it works continuously without fatigue, letting a small number of specialists cover a large population.
It usually cannot explain how it reached a decision, so a person affected cannot be told why. And it reproduces the biases in its training data while appearing objective, which can make unfair outcomes harder to challenge.
A farmer can photograph an affected leaf with a phone and a model identifies the crop disease and suggests treatment. This reaches farms that an agricultural extension officer could not visit often enough, and gives an answer within seconds rather than days.
Benefits: no fatigue or distraction, and mobility for non-drivers. Risks: unfamiliar situations, and unclear liability.
The volume and the pattern-matching suit AI; the cost is blocked legitimate transactions with no explanation.
(a) speed and consistency (b) inherited bias and no explanation (c) AI prioritises, humans decide — keeping the benefit and the accountability
These questions come from the CS Fundamentals lessons — each topic has its own notes, worked examples and an interactive diagram.