A Level Computer Science (9618) — MCQs & Practice Questions

340 multiple-choice questions and 254 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 A Level Computer Science (9618) notes first, then come back to practise.

01

Information representation

Multiple choice · 24

Q11011₂ in decimal is:

  1. A9
  2. B11
  3. C13
  4. D23
Show answer

Correct answer: B — 11

Place values 8, 4, 2, 1: 8 + 0 + 2 + 1 = 11.

Q2How many values can 6 bits represent?

  1. A12
  2. B36
  3. C64
  4. D128
Show answer

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:

  1. A155
  2. B255
  3. C256
  4. D1515
Show answer

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:

  1. AB6
  2. B6B
  3. CA6
  4. DB5
Show answer

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:

  1. A1011
  2. B1101
  3. C1110
  4. D1001
Show answer

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:

  1. A7 characters
  2. B49 characters
  3. C128 characters
  4. D256 characters
Show answer

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:

  1. A100000000 stored correctly
  2. B00000000 with overflow
  3. C11111111
  4. Dan error message
Show answer

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?

  1. Ait is a different number system
  2. Bit is four times shorter and converts with no arithmetic
  3. Ccomputers store hex directly
  4. Dit uses fewer symbols
Show answer

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?

  1. A4
  2. B8
  3. C16
  4. D32
Show answer

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:

  1. A7 characters
  2. B64 characters
  3. C128 characters
  4. D256 characters
Show answer

Correct answer: C — 128 characters

2⁷ = 128. Extended ASCII adds an eighth bit to reach 256.

Q11The file size of a bitmap depends on:

  1. Aresolution only
  2. Bcolour depth only
  3. Cboth resolution and colour depth
  4. Dthe number of colours actually used
Show answer

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:

  1. A200 000 bits
  2. B1 600 000 bits
  3. C200 000 bytes
  4. D1 600 000 bytes
Show answer

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:

  1. Areduces the file size
  2. Bimproves accuracy and increases the file size
  3. Chas no effect on size
  4. Dreduces the number of channels
Show answer

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:

  1. Ahow often the wave is measured
  2. Bhow many bits store each measurement
  3. Cthe length of the recording
  4. Dthe number of channels
Show answer

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:

  1. Ahalves the file size
  2. Bdoubles the file size
  3. Chas no effect
  4. Dtriples the file size
Show answer

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:

  1. Ait was a coincidence
  2. Bit keeps existing ASCII text readable
  3. CASCII is a subset of Chinese
  4. Dit saves processing time
Show answer

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.

Q17Lossless compression means the original file can be:

  1. Aapproximated closely
  2. Breconstructed exactly
  3. Cnever recovered
  4. Dplayed faster
Show answer

Correct answer: B — reconstructed exactly

Nothing is discarded — the data is only described more briefly, so the original is recoverable bit for bit.

Q18Which file type should NOT be compressed lossily?

  1. Aa photograph
  2. Ba music track
  3. Ca spreadsheet
  4. Da video
Show answer

Correct answer: C — a spreadsheet

A changed digit in a spreadsheet is a wrong number. Lossy methods rely on perceptual tolerance, and numeric data has none.

Q19Run-length encoding of AAABBBBCC gives:

  1. A3A4B2C
  2. BABC
  3. C9ABC
  4. D3A3B3C
Show answer

Correct answer: A — 3A4B2C

Three A, four B and two C, each written as a count followed by the value.

Q20Run-length encoding can increase a file size when:

  1. Athe file is very large
  2. Bthere is little repetition in the data
  3. Cthe file is text
  4. Dthe counts are small
Show answer

Correct answer: B — there is little repetition in the data

With no runs, every single value is stored with a count of 1 alongside it, so the encoded file has twice as many items.

Q21JPEG compression works by:

  1. Astoring every pixel exactly
  2. Bdiscarding colour detail the eye is unlikely to notice
  3. Cremoving every second pixel
  4. Dconverting to text
Show answer

Correct answer: B — discarding colour detail the eye is unlikely to notice

The eye is far more sensitive to brightness than to fine colour variation, so colour precision is where the data is cut.

Q22Repeatedly saving a JPEG causes:

  1. Ano change
  2. Bprogressive quality loss
  3. Cthe file to grow
  4. Da lossless result
Show answer

Correct answer: B — progressive quality loss

Each save discards a little more information. This is generation loss, and it is why an uncompressed master should be kept.

Q23The main advantage of solid-state over magnetic storage is:

  1. Alower cost per gigabyte
  2. Bno moving parts, so faster and shock-resistant
  3. Cunlimited writes
  4. Dlarger capacity
Show answer

Correct answer: B — no moving parts, so faster and shock-resistant

It costs more per gigabyte and has limited write endurance. Speed and durability are what it buys.

Q24Compressing an already-compressed file usually:

  1. Ahalves it again
  2. Bachieves little or nothing
  3. Crestores lost quality
  4. Dconverts it to lossless
Show answer

Correct answer: B — achieves little or nothing

Compression removes redundancy, and once it is gone there is nothing left to exploit — the second pass may even add a little overhead.

Exam-style questions · 18

Q1[2 marks]
Why do computers use the binary number system?
Answer

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.

Q2[2 marks]
Convert 11010₂ to decimal.
Answer

Place values 16, 8, 4, 2, 1: 16 + 8 + 0 + 2 + 0 = 26.

Q3[2 marks]
State one advantage of hexadecimal over binary for a programmer.
Answer

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.

Q4[4 marks]
Convert 2C₁₆ to binary and then to decimal.
Mark scheme
  1. 2 in hex is 0010 in binaryfour bits per hex digit[1]
  2. C is 12 in decimal, which is 1100A=10, B=11, C=12, D=13, E=14, F=15[1]
  3. Together: 00101100₂concatenate the groups, do not add them[1]
  4. Decimal: 32 + 8 + 4 = 44or 2×16 + 12 = 44 directly from hex[1]

2C₁₆ = 00101100₂ = 44₁₀

Q5[4 marks]
Add the 8-bit binary numbers 11001010 and 01110011. State whether overflow occurs.
Mark scheme
  1. Adds column by column from the right, carrying where a column totals 2[1]
  2. Result within 8 bits: 01000010 with a carry out of the leftmost column[1]
  3. In decimal 202 + 115 = 317, which exceeds the 8-bit maximum of 255[1]
  4. Overflow occurs — the true answer needs 9 bits, so the stored 8-bit result is incorrectthe consequence must be stated[1]

Carry out of the final column; overflow occurs because 317 > 255.

Q6[6 marks]
A system stores text using ASCII and images using 24-bit colour.
  1. How many different characters can 7-bit ASCII represent, and why is this insufficient for Urdu?
  2. How many distinct colours can 24-bit colour represent?
  3. Calculate the file size in KB of an uncompressed 100 × 200 pixel image in 24-bit colour.
Mark scheme
  1. 2⁷ = 128 characters[1]
  2. Urdu uses a different script with many additional letterforms, and 128 slots are already taken by English letters, digits and punctuation — so Unicode is used insteadnaming Unicode expected[1]
  3. 2²⁴ = 16 777 216 coloursaccept "about 16.7 million"[1]
  4. Total pixels = 100 × 200 = 20 000[1]
  5. Each pixel takes 24 bits = 3 bytes, so 20 000 × 3 = 60 000 bytesconverting bits to bytes is the step most often missed[1]
  6. 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

Q7[2 marks]
State one advantage and one disadvantage of Unicode compared with ASCII.
Answer

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.

Q8[2 marks]
An image has a colour depth of 8 bits. How many different colours can each pixel be?
Answer

2⁸ = 256 colours.

Q9[2 marks]
Define sample rate and sample resolution.
Answer

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.

Q10[4 marks]
A bitmap image is 1024 pixels wide and 768 pixels high with a colour depth of 16 bits. Calculate the file size in kilobytes.
Mark scheme
  1. Total pixels = 1024 × 768 = 786 432[1]
  2. Total bits = 786 432 × 16 = 12 582 912[1]
  3. Bytes = 12 582 912 ÷ 8 = 1 572 864dividing by 8 is the step most often missed[1]
  4. Kilobytes = 1 572 864 ÷ 1024 = 1536 KB[1]

1536 KB (1.5 MB)

Q11[4 marks]
A 30-second mono sound clip is recorded at 44 100 Hz with a resolution of 16 bits. Calculate the file size in megabytes, and state the effect of recording in stereo.
Mark scheme
  1. Bits = 44 100 × 16 × 30rate × resolution × seconds[1]
  2. = 21 168 000 bits[1]
  3. Bytes = 2 646 000, so ÷ 1 048 576 = 2.52 MBaccept 2.65 MB using 1 000 000[1]
  4. Stereo records two channels, so the file size doubles to about 5 MB[1]

About 2.5 MB mono, doubling to about 5 MB in stereo

Q12[6 marks]
A photographer must email a set of images but the files are too large.
  1. Explain two ways the file size of a bitmap image could be reduced, and the cost of each.
  2. Explain why increasing the colour depth from 8 to 24 bits triples the file size.
  3. Explain why the letters of the alphabet were given consecutive codes in ASCII.
Mark scheme
  1. Reduce the resolution — fewer pixels means a smaller file, at the cost of visible detail[1]
  2. Reduce the colour depth — fewer bits per pixel, at the cost of colour accuracy and possible banding in smooth gradientsaccept compression as a third method[1]
  3. The file size is width × height × colour depth, and only the depth has changed[1]
  4. 24 is three times 8, and the size is directly proportional to the depth, so the file is three times as largethe proportionality is the mark[1]
  5. Consecutive codes mean sorting alphabetically is the same as sorting numerically[1]
  6. And converting between upper and lower case is a fixed addition or subtraction of 32, both of which would be far harder with arbitrary assignments[1]

(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

Q13[2 marks]
State two reasons for compressing a file.
Answer

It uses less storage space, and it transmits faster over a network while using less bandwidth — which reduces cost on a metered connection.

Q14[2 marks]
Explain the difference between lossy and lossless compression.
Answer

Lossless reduces the file size in a way that allows the original to be reconstructed exactly. Lossy discards some data permanently, giving a much smaller file that can never be restored to the original.

Q15[2 marks]
Why must a program file not be compressed using a lossy method?
Answer

Lossy compression alters the data, and in a program every bit matters — changing even one instruction could stop the program running or make it behave incorrectly. Lossy methods rely on human perception tolerating small changes, and a computer executing code has no such tolerance.

Q16[4 marks]
Apply run-length encoding to RRRRRGGGBBBBBBBB and comment on when this method works poorly.
Mark scheme
  1. Runs identified: five R, three G, eight B[1]
  2. Encoded as 5R 3G 8B — six items instead of sixteen characters[1]
  3. It works poorly when adjacent values rarely repeat, such as in a photograph where neighbouring pixels differ slightly[1]
  4. In that case each run has length 1 and the encoding stores a count as well as the value, making the file larger than the originalthe enlargement is the key insight[1]

5R3G8B; it fails on data with little repetition, where it can increase the file size.

Q17[4 marks]
Compare magnetic, optical and solid-state storage, giving one advantage and one disadvantage of solid-state.
Mark scheme
  1. Magnetic uses magnetised regions on spinning platters — large capacity and cheap per gigabyte[1]
  2. Optical uses pits read by laser — portable and cheap, but small capacity and slow[1]
  3. Solid-state advantage: no moving parts, so it is much faster, silent and resistant to being dropped[1]
  4. Disadvantage: higher cost per gigabyte, and each memory cell tolerates only a limited number of writesthe write-endurance point is the stronger one[1]

Magnetic cheap and large, optical portable, solid-state fast but dearer with limited write endurance.

Q18[6 marks]
A school is setting up a system to store student photographs, exam scripts as scanned documents, and the school database.
  1. Recommend a compression approach for the photographs, with a reason.
  2. Recommend one for the database, with a reason.
  3. Explain why the total storage needed cannot be reduced indefinitely by compressing repeatedly.
Mark scheme
  1. Photographs: lossy compression such as JPEG[1]
  2. The reduction is large and the discarded detail is not noticeable in a photograph viewed normally, so the loss costs nothing in practice[1]
  3. Database: lossless compression, or none at all[1]
  4. Every value must be recoverable exactly — a changed digit in a mark or a date is simply wrong data, with no perceptual tolerance to exploit[1]
  5. Lossless compression works by removing repetition, and once the repetition is gone there is nothing further to remove[1]
  6. Compressing an already-compressed file usually achieves nothing and can make it slightly larger, since the compression data itself must be storedaccept that repeated lossy compression degrades quality instead[1]

(a) lossy — the loss is imperceptible (b) lossless — every value must be exact (c) once repetition is removed there is nothing left to compress

02

Communication

Multiple choice · 14

Q1Data is split into packets before transmission mainly because:

  1. APackets travel faster than whole files
  2. BLost data can be resent in small pieces and links can be shared
  3. CComputers cannot store whole files
  4. DIt encrypts the data
Show answer

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?

  1. ATCP, because reliability matters most
  2. BUDP, because late data is useless anyway
  3. CHTTP, because it is a web application
  4. DSMTP, because it streams
Show answer

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:

  1. AAssigned by your router each time you connect
  2. BFixed to the hardware and used only on the local network
  3. CAlways a public internet address
  4. DUsed to encrypt traffic
Show answer

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:

  1. AEncrypt web traffic
  2. BTranslate domain names into IP addresses
  3. CSplit data into packets
  4. DChoose the fastest route
Show answer

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:

  1. AData travels faster
  2. BEach layer can be changed without disturbing the others
  3. CFewer packets are needed
  4. DIt removes the need for addresses
Show answer

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:

  1. AA single SYN message
  2. BA three-way handshake: SYN, SYN-ACK, ACK
  3. CA DNS lookup
  4. DAn encrypted certificate exchange
Show answer

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:

  1. Athe same as the internet
  2. Ba collection of pages accessed over the internet
  3. Ca type of cable
  4. Da browser
Show answer

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:

  1. AHTML into a page
  2. Ba domain name into an IP address
  3. Ctext into binary
  4. DHTTP into HTTPS
Show answer

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:

  1. Aafter a year
  2. Bwhen the browser is closed
  3. Cnever
  4. Dwhen the page reloads
Show answer

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:

  1. Arun a program
  2. Binfect a computer with a virus
  3. Cstore text data for a website
  4. Daccess any file on the disk
Show answer

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:

  1. Ais faster
  2. Bencrypts the traffic
  3. Cuses a different port only
  4. Dworks without DNS
Show answer

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:

  1. Athe site is trustworthy
  2. Bthe connection is encrypted and the certificate is valid
  3. Cno cookies are used
  4. Dthe site is government approved
Show answer

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?

  1. Athe HTML is parsed
  2. Ba DNS lookup
  3. CCSS is applied
  4. Dcookies are sent
Show answer

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:

  1. Aa browser
  2. Bthe company providing the internet connection
  3. Ca type of server
  4. Da protocol
Show answer

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.

Exam-style questions · 12

Q1[2 marks]
State the difference between a LAN and a WAN.
Answer

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.

Q2[2 marks]
Explain the purpose of an IP address and a MAC address.
Answer

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.

Q3[3 marks]
Describe what happens when data is split into packets for transmission.
Answer

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.

Q4[8 marks]
A school is setting up a network for 30 computers in one building.
  1. State whether a LAN or a WAN is appropriate and justify your choice. [2]
  2. Describe the function of a router and of a switch in this network. [4]
  3. State two advantages of networking the computers rather than leaving them standalone. [2]
Mark scheme
  1. A LAN[1]
  2. The computers are all within a single building and the school owns the cabling[1]
  3. A switch connects devices within the LAN[1]
  4. It forwards each frame only to the port of the intended recipient, using MAC addresses[1]
  5. A router connects the LAN to another network, usually the internet[1]
  6. It forwards packets between networks using IP addresses[1]
  7. Advantage: files and printers can be shared[1]
  8. Advantage: software and backups can be managed centrally[1]
Q5[7 marks]
A student enters a web address into a browser and the page loads.
  1. Describe the role of the DNS in this process. [3]
  2. Explain the difference between HTTP and HTTPS. [2]
  3. State two reasons a school might use a firewall on this connection. [2]
Mark scheme
  1. The browser sends the domain name to a DNS server[1]
  2. The server looks up the matching IP address[1]
  3. The IP address is returned and the browser requests the page from that server[1]
  4. HTTPS encrypts the data in transit, HTTP sends it in plain text[1]
  5. So HTTPS protects information such as passwords from being read if intercepted[1]
  6. To block access to unsuitable or unauthorised sites[1]
  7. To inspect incoming traffic and block unauthorised access to the network[1]
Q6[5 marks]
A company is choosing between a wired and a wireless network for its office.
  1. Give one advantage of a wired connection. [1]
  2. Give one advantage of a wireless connection. [1]
  3. The company handles confidential data. Describe one security measure it should apply to a wireless network and explain how it helps. [3]
Mark scheme
  1. Faster and more reliable, with less interference[1]
  2. Devices can be moved freely and no cabling is needed[1]
  3. Use WPA encryption on the wireless network[1]
  4. Data sent over the air is scrambled[1]
  5. So anyone intercepting the signal cannot read it without the keyaccept MAC filtering or a strong passphrase, explained[1]
Q7[2 marks]
Explain the difference between the internet and the world wide web.
Answer

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.

Q8[2 marks]
What is the purpose of DNS?
Answer

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.

Q9[2 marks]
State two uses of cookies.
Answer

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.

Q10[4 marks]
Describe the sequence of events from entering a URL to a web page being displayed.
Mark scheme
  1. The browser extracts the domain name and requests its IP address from a DNS server[1]
  2. The DNS server returns the IP address, querying other DNS servers if necessary[1]
  3. The browser sends an HTTP request to that address and the server responds with the HTML[1]
  4. The browser requests the further resources the page references, then parses the HTML, applies the CSS and renders the page[1]

DNS lookup → HTTP request → server response → further resource requests → parse and render.

Q11[4 marks]
Explain how HTTPS protects a user entering payment details, and state one thing the padlock does not guarantee.
Mark scheme
  1. The data is encrypted in the browser before it is transmitted[1]
  2. so anyone intercepting it on the network sees only ciphertext and cannot read the card details[1]
  3. A digital certificate issued by a trusted authority supplies the public key and confirms the site's identity[1]
  4. The padlock does not guarantee the site is honest — only that the connection is encrypted and the site is genuinely the one named on the certificatea fraudulent site can hold a valid certificate[1]

Encryption in transit plus a certificate proving identity; the padlock says nothing about the site's honesty.

Q12[6 marks]
An online shop uses cookies and HTTPS.
  1. Explain the difference between a session cookie and a persistent cookie, with a use for each.
  2. Explain why cookies raise privacy concerns.
  3. Explain why a cookie cannot infect the visitor's computer.
Mark scheme
  1. A session cookie is held in memory and deleted when the browser closes — used to keep the customer logged in while moving between pages[1]
  2. A persistent cookie is stored on disk and survives until it expires — used to remember preferences or a basket between visits[1]
  3. A cookie set by an advertiser present on many different sites can be read on each of them[1]
  4. so a record of the user's browsing can be assembled across sites without their being aware of itthe cross-site point is the concern[1]
  5. A cookie is a small text file, not a program, so it cannot be executed[1]
  6. It can only be read by the site that set it, and cannot access other files on the machine — the genuine risk is to privacy, not to the computer[1]

(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

03

Hardware

Multiple choice · 32

Q1Which of these is volatile?

  1. AHard disk
  2. BSSD
  3. CRAM
  4. DDVD
Show answer

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:

  1. Acontrol unit
  2. BALU
  3. Cprogram counter
  4. Dcache
Show answer

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?

  1. AFetch
  2. BDecode
  3. CExecute
  4. DStore
Show answer

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:

  1. Ait is faster that way
  2. Bmemory never sends addresses to the CPU
  3. Cit carries only one bit
  4. Dit is shorter
Show answer

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:

  1. Athe CPU overheats
  2. Bit swaps data to much slower storage
  3. Cthe monitor cannot keep up
  4. Dthe address bus fills
Show answer

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?

  1. ARAM
  2. BCache
  3. CRegisters
  4. DSSD
Show answer

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:

  1. Ais always slower
  2. Bcan execute four instruction streams at once
  3. Chas no cache
  4. Duses no RAM
Show answer

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:

  1. Athe address of the next instruction
  2. Bthe instruction currently being decoded
  3. Cthe ALU result
  4. Dthe whole program
Show answer

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.

Q9Which of these is both an input and an output device?

  1. AKeyboard
  2. BPrinter
  3. CTouchscreen
  4. DScanner
Show answer

Correct answer: C — Touchscreen

It displays information and senses where the user touches, performing both functions in one unit.

Q10A sensor produces:

  1. Aa digital value
  2. Ban analogue value
  3. Ca binary file
  4. Da decision
Show answer

Correct answer: B — an analogue value

The reading varies continuously, so an analogue-to-digital converter is needed before a processor can use it.

Q11The role of a sensor in a control system is to:

  1. Adecide what action to take
  2. Bmeasure a physical quantity
  3. Coperate a motor
  4. Dstore readings
Show answer

Correct answer: B — measure a physical quantity

Deciding is the microprocessor's job and acting is the actuator's. The sensor only measures.

Q12The most suitable sensor for an automatic door is:

  1. ApH sensor
  2. Binfrared or proximity sensor
  3. Cmoisture sensor
  4. Dpressure sensor in the ceiling
Show answer

Correct answer: B — infrared or proximity sensor

It detects a person approaching. A pressure mat would also work, but an infrared sensor detects them before they arrive.

Q13For printing 5000 pages a month, the better choice is:

  1. Ainkjet, because it is cheaper to buy
  2. Blaser, because of speed and cost per page
  3. Ca 3D printer
  4. Deither — there is no difference
Show answer

Correct answer: B — laser, because of speed and cost per page

At that volume the running cost dominates the purchase price, and an inkjet would be far slower as well.

Q14An actuator is:

  1. Aan input device
  2. Ban output device that performs a physical action
  3. Ca type of sensor
  4. Da converter
Show answer

Correct answer: B — an output device that performs a physical action

Motors, valves and heaters change something physical rather than presenting information to a person.

Q15An ADC is needed because:

  1. Asensors are slow
  2. Bprocessors cannot use analogue signals directly
  3. Cit saves power
  4. Dsensors are digital
Show answer

Correct answer: B — processors cannot use analogue signals directly

The sensor produces a continuously varying value and the processor works only in discrete digital values.

Q16A barcode is read by:

  1. Aweighing the product
  2. Bmeasuring light reflected from bars and spaces
  3. Ca magnetic strip
  4. Dtyping the number
Show answer

Correct answer: B — measuring light reflected from bars and spaces

Dark bars reflect less light than light spaces, and the resulting pattern is converted into the product number.

Q17Which is volatile?

  1. AROM
  2. BRAM
  3. Chard disk
  4. DDVD
Show answer

Correct answer: B — RAM

RAM loses its contents the moment power is removed, which is why unsaved work disappears in a power cut.

Q18ROM contains:

  1. Athe operating system
  2. Bthe start-up instructions
  3. Cthe user's files
  4. Dvirtual memory
Show answer

Correct answer: B — the start-up instructions

It holds the small boot program that finds and loads the operating system. The OS itself is far too large and lives on disk.

Q19Optical storage reads data using:

  1. Aa magnetic head
  2. Ba laser
  3. Ctrapped charge
  4. Da rotating drum
Show answer

Correct answer: B — a laser

A laser is reflected differently by pits and flat areas, and that difference is read as the bit pattern.

Q20The main disadvantage of solid-state storage is:

  1. Ait is slow
  2. Bit has moving parts
  3. Ccost per gigabyte and limited write endurance
  4. Dit is volatile
Show answer

Correct answer: C — cost per gigabyte and limited write endurance

It is fast, silent and has no moving parts. What it costs is money and a finite number of writes per cell.

Q21Virtual memory is located:

  1. Ainside the CPU
  2. Bin ROM
  3. Con secondary storage
  4. Din cache
Show answer

Correct answer: C — on secondary storage

It is disk space treated as though it were RAM, which is exactly why using it is so much slower than real memory.

Q22A machine paging heavily shows:

  1. Ahigh CPU usage only
  2. Ba slow response with constant disk activity
  3. Ca full screen
  4. Dno symptoms
Show answer

Correct answer: B — a slow response with constant disk activity

The processor is waiting on the disk rather than computing, so the disk light is busy while the CPU is not.

Q23The best remedy for constant paging is:

  1. Aa faster disk
  2. Bmore RAM
  3. Ca bigger monitor
  4. Ddefragmenting
Show answer

Correct answer: B — more RAM

More RAM means the pages never need to leave memory. A faster disk makes an expensive operation slightly less expensive.

Q24For an archive of rarely accessed files, the best value is:

  1. Asolid state
  2. Bmagnetic hard disks
  3. CRAM
  4. Dcache
Show answer

Correct answer: B — magnetic hard disks

Capacity per rupee is what matters when speed is irrelevant, and magnetic disks are far cheaper at large capacities.

Q25A two-input AND gate outputs 1 when the inputs are:

  1. A0 and 0
  2. B0 and 1
  3. C1 and 0
  4. D1 and 1
Show answer

Correct answer: D — 1 and 1

AND requires every input to be 1. Any 0 forces the output to 0.

Q26A NOR gate outputs 1 when:

  1. Aboth inputs are 1
  2. Bboth inputs are 0
  3. Cthe inputs differ
  4. Dalways
Show answer

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.

Q27The expression (A + B)′ is equivalent to:

  1. AA′ + B′
  2. BA′ · B′
  3. CA · B
  4. DA ⊕ B
Show answer

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.

Q28A truth table for a circuit with 4 inputs has how many rows?

  1. A4
  2. B8
  3. C16
  4. D32
Show answer

Correct answer: C — 16

2⁴ = 16. Each additional input doubles the number of combinations.

Q29Simplify A·B + A·B′.

  1. AA
  2. BB
  3. CA·B
  4. D0
Show answer

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.

Q30In a half adder, the Carry output is produced by:

  1. Aan XOR gate
  2. Ban AND gate
  3. Can OR gate
  4. Da NOT gate
Show answer

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.

Q31Which is TRUE in Boolean algebra?

  1. AA + A = 2A
  2. BA + 1 = 1
  3. CA · A = A²
  4. DA + A′ = 0
Show answer

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.

Q32NAND is described as a universal gate because:

  1. Ait is the fastest gate
  2. Bany logic circuit can be built from NAND gates alone
  3. Cit has the most inputs
  4. Dit uses no power
Show answer

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.

Exam-style questions · 24

Q1[2 marks]
Differentiate between RAM and secondary storage.
Answer

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.

Q2[2 marks]
Name the two main components of the CPU and state the function of each.
Answer

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.

Q3[2 marks]
What is held in the program counter, and why must it change during every cycle?
Answer

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.

Q4[4 marks]
Describe the four stages of the fetch–execute cycle.
Mark scheme
  1. Fetch: the address in the program counter is placed on the address bus and the instruction is brought back along the data bus into the instruction registermention of a bus expected[1]
  2. Decode: the control unit interprets the instruction to determine the operation and its operands[1]
  3. Execute: the ALU carries out the operation[1]
  4. Store: the result is written back to a register or to memory, and the cycle repeatsthe repetition should be stated[1]

Fetch, decode, execute, store — repeated for every instruction.

Q5[4 marks]
Explain the purpose of the address bus, the data bus and the control bus, and state which of them is unidirectional.
Mark scheme
  1. The address bus carries the memory address being accessed[1]
  2. The data bus carries the actual data or instruction[1]
  3. The control bus carries signals such as read and write[1]
  4. The address bus is unidirectional — addresses only ever travel from the CPU to memory, whereas data travels both waysthe reason is required[1]

Address = where (one-way), data = what (two-way), control = read or write.

Q6[6 marks]
A student is choosing between two laptops. Laptop A has a 3.2 GHz single-core processor, 4 GB RAM and a 1 TB hard disk. Laptop B has a 2.4 GHz quad-core processor, 16 GB RAM and a 512 GB SSD.
  1. Explain which laptop is likely to feel faster in everyday use.
  2. Explain one advantage Laptop A still has.
  3. Explain why clock speed alone is a poor way to compare processors.
Mark scheme
  1. Laptop B[1]
  2. Four cores can execute four instruction streams at once, so it handles several programs far better than one faster core[1]
  3. 16 GB of RAM means far less swapping to disk, and the SSD has no moving parts so it reads much faster than a hard diskeither point accepted[1]
  4. Laptop A has 1 TB of storage against 512 GB, so it holds roughly twice as many filescapacity is the only advantage here[1]
  5. Clock speed measures cycles per second on ONE core, so it says nothing about how many cores there are[1]
  6. It also ignores cache size and the amount of RAM, both of which decide how often the CPU has to wait for data[1]

(a) Laptop B — more cores, far more RAM, and an SSD (b) twice the storage capacity (c) clock speed ignores cores, cache and RAM

Q7[2 marks]
Give one device that is both an input and an output device, and explain why.
Answer

A touchscreen. It displays information, which is output, and senses where the user touches, which is input — both functions in one device.

Q8[2 marks]
Why is an analogue-to-digital converter needed between a sensor and a microprocessor?
Answer

A sensor produces a continuously varying analogue reading, while a microprocessor can only work with digital values. The ADC converts the analogue signal into a number the processor can use.

Q9[2 marks]
Name a suitable sensor for an automatic greenhouse watering system and explain your choice.
Answer

A moisture sensor in the soil. It measures the water content directly, which is the quantity the system needs to control, so watering can be triggered when the soil dries below a preset level.

Q10[4 marks]
Compare inkjet and laser printers, recommending one for a business printing 2000 invoices a month.
Mark scheme
  1. An inkjet sprays ink droplets; it is cheap to buy and gives good colour quality, but is slow with a high cost per page[1]
  2. A laser uses toner and a drum; it is faster with a much lower cost per page, though dearer to buy[1]
  3. Recommend the laser printer[1]
  4. 2000 pages a month is high volume, so the lower cost per page and greater speed outweigh the higher purchase price, and invoices need no photographic colour qualitythe justification must use the figures given[1]

Laser — high volume makes speed and cost per page decisive, and invoices need no photo quality.

Q11[4 marks]
Describe how a barcode reader works and give two advantages over typing a product code by hand.
Mark scheme
  1. A light or laser is shone at the barcode and the reflection is measured — dark bars reflect less light than the light spaces[1]
  2. The pattern of reflections is converted into a number, which is looked up in the product database[1]
  3. Advantage: it is much faster than typing a long code[1]
  4. Advantage: it is far more accurate — no mistyping — and a check digit in the code catches any misread[1]

Reflected light is read as a pattern and converted to a number; faster and more accurate than typing.

Q12[6 marks]
An automatic car park barrier raises when a car approaches and a valid ticket is presented.
  1. Name two input devices the system would use and state what each detects.
  2. Name the output device that raises the barrier.
  3. Explain why the sensors alone cannot operate the barrier.
Mark scheme
  1. A proximity or infrared sensor to detect that a vehicle is present at the barrier[1]
  2. A barcode or card reader to read the ticket presented by the driveraccept a camera reading the number plate[1]
  3. An actuator — a motor — raises and lowers the barrier arm[1]
  4. Sensors only measure; they produce readings and make no decisions[1]
  5. A microprocessor must compare the ticket against stored valid tickets and check that a vehicle is actually present[1]
  6. Only then does it send a signal to the actuator, so the processor is what turns two readings into an action[1]

(a) a proximity sensor and a ticket reader (b) a motor as actuator (c) sensors only measure — the processor compares and decides

Q13[2 marks]
State two differences between RAM and ROM.
Answer

RAM is volatile and loses its contents when the power is removed; ROM is non-volatile and retains them. RAM can be written to freely and holds the programs currently running; ROM is not normally written to and holds the start-up instructions.

Q14[2 marks]
Why is secondary storage needed as well as RAM?
Answer

RAM is volatile, so everything in it is lost when the machine is switched off, and it is comparatively small and expensive. Secondary storage retains data permanently without power and provides far greater capacity at a much lower cost.

Q15[2 marks]
Explain one advantage of solid-state storage over magnetic storage.
Answer

It has no moving parts, so it accesses data much faster, uses less power, makes no noise and is far more resistant to damage from being dropped or vibrated.

Q16[4 marks]
Explain what virtual memory is and how it works.
Mark scheme
  1. Virtual memory is an area of secondary storage used as though it were additional RAM[1]
  2. It is used when the programs being run need more memory than the physical RAM provides[1]
  3. Pages of memory not currently in use are written out to disk, freeing real RAM for active data[1]
  4. When a page is needed again it is read back and another is written out — a process called paging or swapping[1]

Disk space used as extra RAM, with unused pages swapped out and read back when needed.

Q17[4 marks]
A computer becomes very slow when many applications are open, and its disk light stays on. Explain the cause and evaluate two possible remedies.
Mark scheme
  1. RAM has filled, so the operating system is using virtual memory and paging to diskthe constant disk activity is the clue[1]
  2. Disk access is thousands of times slower than RAM, so every switch between programs now waits on the disk[1]
  3. Installing more RAM is the better remedy: it removes the need to page at all[1]
  4. Fitting a faster SSD helps but only shortens each swap — it reduces the symptom while leaving the cause in placethe distinction is the mark[1]

RAM is full and the OS is paging. More RAM removes the cause; a faster disk only shortens each delay.

Q18[6 marks]
A hospital is specifying storage for three purposes: the machine that runs monitoring software, an archive of patient scans, and copies of records to be carried between sites.
  1. Recommend a storage type for each, with a reason.
  2. Explain why the monitoring machine should have enough RAM to avoid virtual memory.
  3. Explain why ROM is still needed in each machine.
Mark scheme
  1. Monitoring machine: solid state, for speed and because it has no moving parts to fail[1]
  2. Archive: magnetic hard disks, for the very large capacity at low cost per gigabyte[1]
  3. Between sites: optical or solid state portable media, as it must be carried and survive handlingeither accepted with justification[1]
  4. If it began paging, the machine would slow unpredictably as it waited on disk access[1]
  5. In a monitoring system a delayed response could be dangerous, so the timing must stay predictable — which means never depending on virtual memorythe safety point is the mark[1]
  6. ROM holds the start-up instructions that run before any disk is read, so the machine can find and load the operating system — without it nothing could boot at all[1]

(a) SSD, magnetic archive, portable media (b) paging would make response times unpredictable, which is unsafe here (c) ROM boots the machine before any disk is available

Q19[2 marks]
Draw the truth table for a two-input NAND gate.
Answer

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.

Q20[2 marks]
State De Morgan's two laws.
Answer

(A · B)′ = A′ + B′ and (A + B)′ = A′ · B′. Complementing a whole expression swaps AND for OR and complements each variable.

Q21[2 marks]
Why are NAND and NOR called universal gates?
Answer

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.

Q22[4 marks]
Construct the truth table for X = A′ · B + A · B′ and state which single gate it is equivalent to.
Mark scheme
  1. Four rows for two inputs, with columns for A′ and B′[1]
  2. A=0,B=0 → 0; A=0,B=1 → 1A′·B is 1 in the second row[1]
  3. A=1,B=0 → 1; A=1,B=1 → 0[1]
  4. Output is 1 exactly when the inputs differ, so this is an XOR gatethe identification is the point of the question[1]

The table matches XOR: output 1 when A and B differ.

Q23[4 marks]
Simplify X = (A + B) · (A + B′) using Boolean laws, naming each law you use.
Mark scheme
  1. Expand: A·A + A·B′ + B·A + B·B′distributive law[1]
  2. A·A = A (idempotent) and B·B′ = 0 (complement)[1]
  3. X = A + A·B′ + A·Bthe zero term disappears[1]
  4. By absorption A + A·anything = A, so X = Anaming the law is required by the question[1]

X = A

Q24[6 marks]
A half adder adds two single bits.
  1. Write the truth table showing Sum and Carry for the four input combinations.
  2. State which gate produces the Sum and which produces the Carry.
  3. Explain why a half adder cannot be used for the second column of a multi-bit addition.
Mark scheme
  1. 0+0 → Sum 0, Carry 0; 0+1 → Sum 1, Carry 0[1]
  2. 1+0 → Sum 1, Carry 0; 1+1 → Sum 0, Carry 1the last row is the whole point — 1+1 in binary is 10[1]
  3. Sum is produced by an XOR gateoutput 1 when the inputs differ[1]
  4. Carry is produced by an AND gateoutput 1 only when both are 1[1]
  5. A half adder has only two inputs, so it has nowhere to accept the carry produced by the previous column[1]
  6. A full adder is needed instead, taking three inputs — A, B and carry-innaming the full adder is expected[1]

(b) XOR for Sum, AND for Carry (c) it has no carry-in input, so a full adder is required

04

Processor Fundamentals

Multiple choice · 16

Q1In the von Neumann architecture, programs and data are:

  1. Astored in separate memories
  2. Bstored in the same memory
  3. Cnever stored
  4. Dstored only in registers
Show answer

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.

Q2The program counter holds:

  1. Athe current instruction
  2. Bthe address of the next instruction
  3. Cthe result of the last operation
  4. Dthe data just fetched
Show answer

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.

Q3During the fetch stage, the instruction is copied from the MDR into the:

  1. AACC
  2. BMAR
  3. CCIR
  4. DPC
Show answer

Correct answer: C — CIR

The current instruction register holds the instruction while the control unit decodes it.

Q4The address bus is unidirectional because:

  1. Ait is cheaper
  2. Bonly the processor generates addresses
  3. Cit carries no data
  4. Dmemory is read-only
Show answer

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.

Q5The von Neumann bottleneck arises because:

  1. Athe clock is too slow
  2. Binstructions and data share one bus
  3. Cthere is too much cache
  4. Dthere are too many cores
Show answer

Correct answer: B — instructions and data share one bus

Sharing a single bus means instruction fetches and data transfers cannot happen simultaneously.

Q6A single-threaded program on a quad-core processor runs:

  1. Afour times faster
  2. Bat about the same speed
  3. Cfour times slower
  4. Dtwice as fast
Show answer

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.

Q7A graphics processor applying the same operation to millions of pixels is an example of:

  1. ASISD
  2. BSIMD
  3. CMISD
  4. DMIMD
Show answer

Correct answer: B — SIMD

One instruction is applied to many data items simultaneously — Single Instruction, Multiple Data.

Q8A disadvantage of running software in a virtual machine is:

  1. Apoorer isolation
  2. Breduced performance from the extra layer
  3. Cit cannot be backed up
  4. Dit needs separate hardware
Show answer

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.

Q9In assembly language, each instruction corresponds to:

  1. Aseveral machine instructions
  2. Bexactly one machine instruction
  3. Cone high-level statement
  4. Done byte of data
Show answer

Correct answer: B — exactly one machine instruction

The one-to-one correspondence is what defines assembly and what makes an assembler sufficient to translate it.

Q10LDM #7 places into the accumulator:

  1. Athe contents of address 7
  2. Bthe value 7
  3. Cthe address 7
  4. Dnothing
Show answer

Correct answer: B — the value 7

The # marks immediate addressing, so the operand is the value itself rather than an address.

Q11To test whether bit 0 is set, you would:

  1. AOR with 00000001
  2. BAND with 00000001
  3. CXOR with 11111111
  4. Dshift left by 1
Show answer

Correct answer: B — AND with 00000001

AND clears every bit the mask has a 0 in, leaving only bit 0 — a non-zero result means it was set.

Q12To set bit 5 without changing any other bit, you would:

  1. AAND with 00100000
  2. BOR with 00100000
  3. CXOR with 00100000
  4. DAND with 11011111
Show answer

Correct answer: B — OR with 00100000

OR forces a 1 where the mask is 1 and leaves other bits alone. XOR would toggle it rather than set it.

Q13XOR with 11111111 has the effect of:

  1. Aclearing every bit
  2. Bsetting every bit
  3. Cinverting every bit
  4. Dleaving the value unchanged
Show answer

Correct answer: C — inverting every bit

XOR flips each bit where the mask holds a 1, so an all-ones mask inverts the whole byte.

Q14A logical left shift of 2 places multiplies an unsigned value by:

  1. A2
  2. B4
  3. C8
  4. D½
Show answer

Correct answer: B — 4

Each place doubles, so two places multiply by 2² = 4 — provided no 1 bits are lost off the end.

Q15An arithmetic right shift differs from a logical one because it:

  1. Ashifts further
  2. Bpreserves the sign bit
  3. Cwraps bits round
  4. Dis faster
Show answer

Correct answer: B — preserves the sign bit

It replicates the sign bit as it shifts, so negative numbers remain negative after the division.

Q16In a cyclic shift, bits moved off one end:

  1. Aare lost
  2. Bbecome zeros
  3. Creappear at the other end
  4. Dset an overflow flag
Show answer

Correct answer: C — reappear at the other end

A cyclic shift wraps the bits around, so no information is lost — unlike logical and arithmetic shifts.

Exam-style questions · 10

Q1[2 marks]
State what is meant by the von Neumann architecture and identify one limitation of it.
Answer

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.

Q2[3 marks]
Describe the fetch stage of the fetch–decode–execute cycle, naming the registers used.
Answer

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.

Q3[2 marks]
Explain why the program counter is incremented during the fetch stage rather than after execution.
Answer

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.

Q4[6 marks]
(a) State the direction of data flow on the address bus and on the data bus, giving a reason for the address bus.
(b) Explain how increasing cache size can improve performance.
(c) A program runs at the same speed on a four-core processor as on a single core. Explain why.
(d) State one advantage and one disadvantage of using virtual machines.
Mark scheme
  1. (a) The address bus is unidirectional; the data bus is bidirectional.Both directions must be stated.[1]
  2. The address bus is one-way because only the processor generates addresses — memory never sends one back.The reason is the mark, not the direction alone.[1]
  3. (b) Cache is faster than main memory and holds recently or frequently used data, so more requests are met without a slow main-memory access.The speed difference must be mentioned.[1]
  4. This reduces the time the processor spends idle waiting for data.Linking to the bottleneck earns the second mark.[1]
  5. (c) The program is single-threaded, so the work is not divided between cores and only one core is used.The software, not the hardware, is the limitation.[1]
  6. (d) Advantage: several isolated systems on one machine, using hardware efficiently. Disadvantage: slower than running directly on hardware, because of the extra software layer.One of each is required.[1]

(a) address one-way, data two-way; (b) fewer slow memory accesses; (c) single-threaded; (d) isolation vs overhead

Q5[2 marks]
Distinguish between SIMD and MIMD, giving a typical use of each.
Answer

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.

Q6[2 marks]
Explain what is meant by assembly language and why it needs only an assembler rather than a compiler.
Answer

Assembly language uses short mnemonics in place of binary machine code, with one instruction corresponding to one machine instruction. Because the relationship is one-to-one, translation is a matter of substituting each mnemonic for its opcode — a much simpler task than compiling a high-level language, where one statement may become many machine instructions.

Q7[2 marks]
Explain the difference between LDM #20 and LDD 20.
Answer

LDM #20 uses immediate addressing: the value 20 itself is loaded into the accumulator. LDD 20 uses direct addressing: the contents of memory address 20 are loaded, which could be any value.

Q8[4 marks]
The accumulator holds 10110110. State the result of (a) AND with 00001111, (b) OR with 01000000, (c) XOR with 11111111, (d) a logical left shift of 1 place.
Mark scheme
  1. (a) 10110110 AND 00001111 = 00000110The mask keeps the lower four bits and clears the upper four.[1]
  2. (b) 10110110 OR 01000000 = 11110110OR sets bit 6; every other bit is unchanged because the mask has 0 there.[1]
  3. (c) 10110110 XOR 11111111 = 01001001XOR with all ones inverts every bit — a one's complement.[1]
  4. (d) 10110110 shifted left 1 = 01101100A zero enters at the right and the leftmost bit is lost, so the value does not simply double here.[1]

(a) 00000110 (b) 11110110 (c) 01001001 (d) 01101100

Q9[6 marks]
A status byte uses bit 2 as an error flag (bit 0 is the least significant).
(a) Give the mask and operation to test whether the flag is set.
(b) Give the mask and operation to set the flag.
(c) Give the mask and operation to clear the flag.
(d) Explain why an arithmetic right shift is used rather than a logical one when dividing a signed number.
Mark scheme
  1. (a) AND with 00000100AND isolates the bit of interest and clears all others.[1]
  2. If the result is non-zero the flag is set; if zero it is clear.The test on the result is part of the answer.[1]
  3. (b) OR with 00000100OR forces a 1 into that position without disturbing the others.[1]
  4. (c) AND with 11111011The complement of the mask — a 0 in the target position clears it, 1s elsewhere preserve.[1]
  5. (d) A logical shift brings in a 0 at the left, which would overwrite the sign bit and turn a negative number positive.The sign bit is the crux.[1]
  6. An arithmetic shift replicates the sign bit instead, so the sign is preserved and the division gives the correct signed result.Both halves — what goes wrong and what is done instead — are needed.[1]

(a) AND 00000100, non-zero means set; (b) OR 00000100; (c) AND 11111011; (d) preserves the sign bit

Q10[2 marks]
State the effect of a logical left shift of 3 places on an unsigned binary value, and one circumstance in which the result would be wrong.
Answer

It multiplies the value by 2³ = 8. The result would be wrong if any bits shifted off the left-hand end were 1s, since those bits are lost — the value would then have overflowed the available word length.

05

System Software

Multiple choice · 16

Q1The always-resident core of an operating system is called the:

  1. Ashell
  2. Bkernel
  3. Cdriver
  4. DBIOS
Show answer

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.

Q2Twenty programs appear to run at once on one core because the OS:

  1. Auses more cores
  2. Bswitches between them very quickly
  3. Ccompresses them
  4. Druns them on the GPU
Show answer

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.

Q3A slow machine with constant disk activity most likely indicates:

  1. Aa virus
  2. BRAM is full and the OS is paging
  3. Ca broken monitor
  4. Dtoo few cores
Show answer

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.

Q4Which operating system type guarantees a maximum response time?

  1. AMulti-user
  2. BReal-time
  3. CSingle-tasking
  4. DDistributed
Show answer

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.

Q5File permissions typically control:

  1. Afile size
  2. Bread, write and execute rights
  3. Cthe file format
  4. Ddisk speed
Show answer

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.

Q6Emptying the recycle bin means the data is:

  1. Asecurely erased
  2. Bstill on the disk until overwritten
  3. Cmoved to the cloud
  4. Dcompressed
Show answer

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.

Q7Virtual memory addressing allows the OS to:

  1. Aincrease physical RAM
  2. Bgive each program a private address space mapped onto real RAM
  3. Cspeed up the CPU
  4. Dremove the need for a disk
Show answer

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.

Q8Adding RAM helps a heavily paging machine more than a faster SSD because it:

  1. Aremoves the need to page at all
  2. Bmakes the disk faster
  3. Creduces CPU load
  4. Dincreases clock speed
Show answer

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.

Q9An interpreter differs from a compiler in that it:

  1. Aproduces an executable file
  2. Btranslates and runs one statement at a time
  3. Cis always faster
  4. Donly works with assembly
Show answer

Correct answer: B — translates and runs one statement at a time

It translates as it executes and produces no output file, which is why it must be present every time the program runs.

Q10Which stage removes comments and whitespace?

  1. Asyntax analysis
  2. Blexical analysis
  3. Ccode generation
  4. Doptimisation
Show answer

Correct answer: B — lexical analysis

Lexical analysis breaks the source into tokens, discarding anything the later stages do not need.

Q11A missing closing bracket would be reported during:

  1. Alexical analysis
  2. Bsyntax analysis
  3. Csemantic analysis
  4. Doptimisation
Show answer

Correct answer: B — syntax analysis

It breaks the grammar of the language, which is exactly what syntax analysis checks.

Q12Using a variable that was never declared is caught during:

  1. Alexical analysis
  2. Bsyntax analysis
  3. Csemantic analysis
  4. Dcode generation
Show answer

Correct answer: C — semantic analysis

The statement can be grammatically perfect while still being meaningless, which is what semantic analysis tests for.

Q13Which translator must be present every time the program runs?

  1. Acompiler
  2. Bassembler
  3. Cinterpreter
  4. Dnone of them
Show answer

Correct answer: C — interpreter

An interpreter translates during execution, so it is required each run. A compiled executable is independent of its compiler.

Q14The main advantage of bytecode is:

  1. Ait runs faster than machine code
  2. Bit is portable across platforms
  3. Cit needs no virtual machine
  4. Dit cannot contain errors
Show answer

Correct answer: B — it is portable across platforms

One compiled file runs anywhere a suitable virtual machine exists. It is slightly slower than native machine code, not faster.

Q15A compiler is usually preferred for released software because:

  1. Ait reports errors one at a time
  2. Bthe executable runs faster and hides the source
  3. Cit needs no translation
  4. Dit is easier to debug
Show answer

Correct answer: B — the executable runs faster and hides the source

Translation has already happened, so it runs faster, and only the executable is distributed rather than the source code.

Q16Optimisation during compilation aims to:

  1. Afind syntax errors
  2. Bproduce faster or smaller code
  3. Cbuild the symbol table
  4. Dconvert tokens to a parse tree
Show answer

Correct answer: B — produce faster or smaller code

It improves the generated code. Error finding and tokenising belong to earlier stages.

Exam-style questions · 11

Q1[2 marks]
What is the kernel of an operating system?
Answer

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.

Q2[2 marks]
Explain how a single-core processor appears to run several programs at once.
Answer

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.

Q3[2 marks]
Why should everyday work not be done from an administrator account?
Answer

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.

Q4[4 marks]
Describe four services provided by an operating system.
Mark scheme
  1. Process management — scheduling which program uses the CPU and for how long[1]
  2. Memory management — allocating RAM to each program and keeping them separate[1]
  3. File management — organising storage into files and folders and controlling access to them[1]
  4. Device management — communicating with hardware through drivers; also accept security and user accounts[1]

Process, memory, file and device management — plus security and the user interface.

Q5[4 marks]
A computer with 4 GB of RAM becomes extremely slow when many applications are open, and the disk activity light stays on. Explain the cause and suggest two solutions.
Mark scheme
  1. RAM has filled, so the OS is moving pages of memory out to disk — paging or swappingthe constant disk light is the clue[1]
  2. Disk access is thousands of times slower than RAM, so every switch between programs now waits on the diskthe speed gap is the explanation[1]
  3. Solution: close unused applications and reduce the number of programs starting automatically[1]
  4. Solution: install more RAM, which removes the need to page rather than merely making paging fasteran SSD helps but does not fix the cause[1]

RAM is full and the OS is paging to disk. Close programs, or add RAM.

Q6[6 marks]
A hospital uses computers for two very different jobs: office machines for administration, and a monitor attached to a patient that must raise an alarm within a guaranteed time.
  1. State the type of operating system suited to each, with a reason.
  2. Explain what "real-time" guarantees and why it matters here.
  3. Explain one way file permissions protect patient records on the office machines.
Mark scheme
  1. Office machines: a single-user multi-tasking operating system, since one person at a time runs several applications togetheraccept multi-user for shared machines[1]
  2. Patient monitor: a real-time operating system[1]
  3. Real-time guarantees that a response occurs within a fixed maximum time, not merely quickly on averagethe guarantee is the distinguishing feature[1]
  4. For a patient monitor an alarm raised late is as dangerous as no alarm, so a predictable worst case matters more than average speed[1]
  5. File permissions grant read, write and execute rights separately to the owner, a group and others[1]
  6. So clinical staff can be given read access to records while administrative staff cannot open them at all, and only authorised users may alter themthe example must fit the hospital[1]

(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

Q7[2 marks]
State two differences between a compiler and an interpreter.
Answer

A compiler translates the whole program before it runs and produces an executable file, whereas an interpreter translates and executes one statement at a time and produces no file. A compiler also reports all errors together at the end, while an interpreter halts at the first error it meets.

Q8[3 marks]
Describe what happens during lexical analysis and syntax analysis.
Answer

Lexical analysis breaks the source into tokens, removes comments and whitespace, and builds the symbol table. Syntax analysis checks that the sequence of tokens obeys the grammar of the language, building a parse tree and reporting errors such as a missing bracket.

Q9[2 marks]
A program contains the statement count = "seven" + 1, where count is declared as an integer. State which stage of compilation reports this and why.
Answer

Semantic analysis. The statement is grammatically well-formed, so it passes syntax analysis, but it is meaningless because a string cannot be added to an integer and assigned to an integer variable — a type mismatch.

Q10[6 marks]
(a) Explain why a developer might use an interpreter while writing a program but a compiler to release it.
(b) State what optimisation does and give one example.
(c) Explain what bytecode is and the advantage it gives.
Mark scheme
  1. (a) An interpreter reports the first error immediately and lets a change be tested without a full rebuild, which suits development.The fast feedback loop is the point.[1]
  2. A compiled executable runs faster and can be distributed without the source code, which suits release.Speed and source privacy are both valid.[1]
  3. (b) Optimisation improves the generated machine code so it runs faster or takes less space.Either faster or smaller is acceptable.[1]
  4. For example, removing code that can never execute, or keeping a frequently used value in a register instead of memory.A concrete example is required for the mark.[1]
  5. (c) Bytecode is an intermediate form produced by the compiler, executed by a virtual machine rather than directly by the processor.The intermediate nature must be stated.[1]
  6. It is portable: the same compiled file runs on any platform with a suitable virtual machine, without recompiling.Portability is the advantage being tested.[1]

(a) fast feedback vs speed and privacy; (b) faster or smaller code; (c) portable intermediate form

Q11[2 marks]
Explain why an assembler is simpler than a compiler.
Answer

In assembly language each mnemonic corresponds to exactly one machine instruction, so translation is largely a matter of substituting opcodes and resolving addresses. A compiler must translate high-level statements that may each become many machine instructions, and must also perform syntax, semantic and optimisation work.

06

Security, privacy and data integrity

Multiple choice · 24

Q1Malware that spreads across a network without any user action is a:

  1. Avirus
  2. Bworm
  3. Ctrojan
  4. Dcookie
Show answer

Correct answer: B — worm

A worm is self-replicating and needs no host file or user. A virus requires someone to run the infected file.

Q2Malware disguised as useful software is a:

  1. Aworm
  2. Btrojan
  3. Ckeylogger
  4. Dfirewall
Show answer

Correct answer: B — trojan

The victim installs it deliberately, believing it to be something else — which is why the disguise is the whole attack.

Q3The most effective defence against brute force is:

  1. Aa longer password only
  2. Blocking the account after failed attempts
  3. Ca firewall
  4. Dencryption
Show answer

Correct answer: B — locking the account after failed attempts

Lockout makes exhaustive guessing impossible regardless of speed. A longer password only increases the time required.

Q4Pharming differs from phishing because:

  1. Ait uses email
  2. Bit redirects you even when you type the correct address
  3. Cit is legal
  4. Dit needs a firewall
Show answer

Correct answer: B — it redirects you even when you type the correct address

DNS settings are altered, so no link needs to be clicked — which is why the standard phishing advice does not protect against it.

Q5A firewall protects against:

  1. Asocial engineering
  2. Bunauthorised network traffic
  3. Ca user giving away a password
  4. Dphysical theft
Show answer

Correct answer: B — unauthorised network traffic

It filters traffic against rules. Attacks that bypass the network entirely, such as a phone call, are outside what it can see.

Q6A telephone call claiming to be from IT and requesting a password is:

  1. Aphishing
  2. Bsocial engineering
  3. Ca DDoS attack
  4. Dpharming
Show answer

Correct answer: B — social engineering

It manipulates a person directly with no technical component at all, which is why training rather than software is the defence.

Q7Two-factor authentication protects against:

  1. Aa stolen password being sufficient
  2. Bviruses
  3. CDDoS attacks
  4. Ddata interception
Show answer

Correct answer: A — a stolen password being sufficient

Even with the correct password, the attacker still needs the second factor, which is typically on a device the owner holds.

Q8The most common route for a successful attack is:

  1. Abreaking encryption
  2. Bpersuading a person to act
  3. Cphysically stealing a server
  4. Dguessing an IP address
Show answer

Correct answer: B — persuading a person to act

Modern encryption is impractical to break, so attackers target the person instead — which is why training belongs in every security answer.

Q9Encryption prevents intercepted data from being:

  1. Acopied
  2. Bunderstood
  3. Cdeleted
  4. Dtransmitted
Show answer

Correct answer: B — understood

The data can still be taken and destroyed. What it cannot be is read, because without the key the ciphertext is meaningless.

Q10In asymmetric encryption, the public key:

  1. Adecrypts messages
  2. Bencrypts messages
  3. Cmust be kept secret
  4. Dis the same as the private key
Show answer

Correct answer: B — encrypts messages

It encrypts only. Even the sender cannot read the message back, which is why publishing the key is safe.

Q11The main problem with symmetric encryption is:

  1. Ait is slow
  2. Bthe key must be shared safely
  3. Cit needs two keys
  4. Dit cannot be broken
Show answer

Correct answer: B — the key must be shared safely

Any channel secure enough to send the key on would have been secure enough for the message itself. Asymmetric encryption exists to solve this.

Q12A brute force attack works by:

  1. Aguessing the algorithm
  2. Btrying every possible key
  3. Cintercepting the message
  4. Dflipping bits
Show answer

Correct answer: B — trying every possible key

It needs no cleverness, only time — which is why key length, and therefore the number of keys to try, is the defence.

Q13Encryption algorithms are published because:

  1. Athey are not important
  2. Bpublic scrutiny finds weaknesses
  3. Cthe key is also public
  4. Dit is a legal requirement
Show answer

Correct answer: B — public scrutiny finds weaknesses

A secret algorithm has been examined by very few people, and an undiscovered flaw is far more dangerous than a public one that has been fixed.

Q14Real secure connections use:

  1. Asymmetric only
  2. Basymmetric only
  3. Casymmetric to exchange a key, then symmetric
  4. Dneither
Show answer

Correct answer: C — asymmetric to exchange a key, then symmetric

Asymmetric solves the key distribution problem, then symmetric handles the bulk data because it is far faster.

Q15Adding one bit to a key length:

  1. Aadds one possible key
  2. Bdoubles the number of possible keys
  3. Chalves the security
  4. Dhas no effect
Show answer

Correct answer: B — doubles the number of possible keys

Each bit has two states, so every extra bit doubles the search space a brute force attack must cover.

Q16Entering card details on an HTTPS page that is actually a fake site:

  1. Ais safe because of the encryption
  2. Bdelivers the details securely to the attacker
  3. Ccannot happen
  4. Dtriggers a browser warning
Show answer

Correct answer: B — delivers the details securely to the attacker

The encryption works perfectly and protects the journey. It says nothing about who is at the other end, which is why phishing defeats it.

Q17Under even parity, the byte 11010010 (including its parity bit) is:

  1. Acorrect
  2. Bcorrupted
  3. Cunreadable
  4. Dodd parity
Show answer

Correct answer: A — correct

Counting the 1s gives four, which is even, so the byte passes the check. That does not guarantee it is right — two flipped bits would also pass.

Q18A single parity check fails to detect an error when:

  1. Aone bit flips
  2. Btwo bits in the same byte flip
  3. Cthe data is text
  4. Dthe byte is all zeros
Show answer

Correct answer: B — two bits in the same byte flip

Two flips restore the original parity, so the count is correct again and nothing is reported.

Q19Which method can identify exactly which bit is wrong?

  1. Asingle parity check
  2. Bparity block
  3. Cecho check
  4. Dcheck digit
Show answer

Correct answer: B — parity block

The failing row and failing column intersect at one cell, so the bit can be corrected without a resend.

Q20A checksum works by:

  1. Asending the data twice
  2. Bcalculating a value from the data and comparing it after transmission
  3. Cadding a parity bit
  4. Dcounting packets
Show answer

Correct answer: B — calculating a value from the data and comparing it after transmission

The receiver recalculates from what arrived. Agreement means the data is almost certainly intact.

Q21A check digit is designed to detect:

  1. Atransmission interference
  2. Bdata entry errors
  3. Clost packets
  4. Dattenuation
Show answer

Correct answer: B — data entry errors

It guards codes typed by people — ISBNs, barcodes, account numbers — rather than data in transit.

Q22In ARQ, a timeout is used to detect:

  1. Aa corrupted packet
  2. Ba packet that never arrived
  3. Ca slow connection
  4. Da parity error
Show answer

Correct answer: B — a packet that never arrived

A lost packet produces no acknowledgement of any kind, so only the expiry of the timer reveals it.

Q23An echo check's main disadvantage is that it:

  1. Acannot detect errors
  2. Bdoubles the amount of data transmitted
  3. Cneeds a parity bit
  4. Donly works on text
Show answer

Correct answer: B — doubles the amount of data transmitted

The entire data is returned, so twice as much travels. It also cannot say which direction the corruption occurred in.

Q24Attenuation means the signal:

  1. Aarrives too early
  2. Bweakens over distance
  3. Csplits into packets
  4. Dis encrypted
Show answer

Correct answer: B — weakens over distance

As it weakens, the difference between a 1 and a 0 becomes harder to distinguish, and eventually bits are misread.

Exam-style questions · 18

Q1[2 marks]
State the difference between a virus and a worm.
Answer

A virus attaches itself to a host file and requires a user to run that file in order to spread. A worm is self-replicating and spreads across a network by itself, needing no user action at all.

Q2[2 marks]
What is a brute force attack, and give one measure that defeats it?
Answer

An attacker tries every possible password in turn until one works. The most effective measure is to lock the account after a small number of failed attempts, which makes exhaustive guessing impossible however fast the attacker is.

Q3[2 marks]
What does a firewall do?
Answer

It examines data entering or leaving a network and blocks anything not permitted by its rules, preventing unauthorised access and filtering out unwanted traffic.

Q4[4 marks]
Explain the difference between phishing and pharming, and state a defence against each.
Mark scheme
  1. Phishing sends a fraudulent message imitating a trusted organisation, containing a link to a fake site the victim must click[1]
  2. Defence: check the sender and the true destination of any link, and never log in through a link — type the address yourself[1]
  3. Pharming uses malicious code to alter DNS settings so that typing the correct address still leads to a fake siteno link is clicked[1]
  4. Defence: anti-malware to prevent the DNS settings being altered, and checking the HTTPS certificate matches the site you intendedtyping the address does not help here[1]

Phishing needs a click; pharming redirects a correctly typed address. Different attacks, different defences.

Q5[4 marks]
A school network must be protected. Describe four security measures and the threat each addresses.
Mark scheme
  1. Firewall — filters incoming and outgoing traffic, preventing unauthorised access from outside[1]
  2. Anti-malware with automatic updates — detects and removes viruses, worms and spyware, and updates close known vulnerabilities[1]
  3. Access levels — each user sees only what they need, so a compromised student account cannot reach staff records[1]
  4. Two-factor authentication or strong password policy with lockout — protects against brute force and stolen passwordsaccept staff training against social engineering[1]

Firewall, anti-malware with updates, access levels, and strong authentication — each matched to its threat.

Q6[6 marks]
A company suffers two incidents: its website becomes unreachable for several hours, and separately an employee's password is obtained by an attacker who telephoned claiming to be from the IT department.
  1. Name and describe the attack in each case.
  2. Explain why a firewall would not have prevented the second incident.
  3. Recommend one measure against each.
Mark scheme
  1. The website incident is a DDoS attack — the server is flooded with requests from many machines until it cannot respond to genuine users[1]
  2. The password incident is social engineering — the attacker manipulated a person into revealing the password, with no technical attack at all[1]
  3. A firewall filters network traffic against a set of rules[1]
  4. The employee volunteered the password over the telephone, which never touched the network — no traffic rule could have detected itthe reason is the mark[1]
  5. Against DDoS: traffic filtering at the firewall, rate limiting, or a service that absorbs and distributes the load[1]
  6. Against social engineering: staff training and a strict procedure that credentials are never given out over the phone, with any such request verified by calling back on a known number[1]

(a) DDoS and social engineering (b) the password never crossed the network (c) traffic filtering, and training with a call-back verification policy

Q7[2 marks]
Explain what encryption does to data being transmitted.
Answer

It scrambles the data using a key so that it becomes meaningless to anyone who intercepts it. Only someone with the correct key can decrypt it back into readable form.

Q8[2 marks]
Does encryption prevent data being intercepted? Explain.
Answer

No. The data can still be intercepted, copied or deleted exactly as before. What encryption prevents is the interceptor understanding what they have taken, because without the key the ciphertext is unreadable.

Q9[2 marks]
Why is a longer encryption key more secure?
Answer

Each extra bit doubles the number of possible keys, so a brute force attack — trying every key in turn — takes far longer. A key short enough to be tried exhaustively offers no real protection.

Q10[4 marks]
Compare symmetric and asymmetric encryption, giving one advantage of each.
Mark scheme
  1. Symmetric uses the same key to encrypt and decrypt[1]
  2. Advantage: it is much faster, so it suits large volumes of data[1]
  3. Asymmetric uses a public key to encrypt and a matching private key to decrypt[1]
  4. Advantage: no secret key needs to be exchanged, which removes the problem of getting the key to the recipient safelythe key distribution problem is the point[1]

Symmetric: one key, fast. Asymmetric: a public/private pair, no shared secret needed.

Q11[4 marks]
Explain why encryption algorithms are made public rather than kept secret.
Mark scheme
  1. A public algorithm can be examined by cryptographers worldwide[1]
  2. so weaknesses are found and corrected, rather than remaining hidden until an attacker discovers one[1]
  3. Security rests entirely on the key, which remains secret — knowing the method does not read the message[1]
  4. A secret algorithm has been checked by very few people, and once leaked offers no protection at all — "security through obscurity" is not security[1]

Public scrutiny finds weaknesses; secrecy rests on the key alone, not on the method.

Q12[6 marks]
A customer buys goods from an online shop and enters card details.
  1. Explain how HTTPS protects the card details in transit.
  2. Explain why the site uses both asymmetric and symmetric encryption.
  3. Explain one thing encryption does NOT protect against here.
Mark scheme
  1. The data is encrypted in the browser before it is sent, so anything intercepted on the way is ciphertext[1]
  2. Only the shop's server holds the key needed to decrypt it, so an interceptor sees nothing usable[1]
  3. Asymmetric encryption is used first, to exchange a symmetric key safely without any prior shared secret[1]
  4. Then symmetric encryption is used for the actual data, because it is far faster for the volume involvedthe combination is the mark[1]
  5. Encryption does not protect the data once it has been decrypted at the destination[1]
  6. If the shop's database is later breached, or if the customer was tricked into sending details to a fake site in the first place, encryption offers no protection — it secured the journey, not the endpointsaccept phishing as the example[1]

(a) encrypted before sending, decryptable only by the server (b) asymmetric to exchange the key, symmetric for speed (c) it protects the journey, not the endpoints — a breached database or a fake site defeats it

Q13[2 marks]
Explain how an even parity check works.
Answer

One bit of each byte is set so that the total number of 1s is even. The receiver counts the 1s in the byte it received; if the total is odd, at least one bit has been corrupted in transmission.

Q14[2 marks]
Give one limitation of a single parity check.
Answer

If two bits flip in the same byte, the parity is restored and the error is not detected. It also cannot identify which bit is wrong, so the data must be resent rather than repaired.

Q15[2 marks]
What is a check digit used for?
Answer

An extra digit calculated from the others and appended to a code such as an ISBN, barcode or account number, so that a data entry error can be detected immediately when the code is typed in.

Q16[4 marks]
Explain how a parity block allows a single corrupted bit to be both detected and corrected.
Mark scheme
  1. Each byte carries a parity bit, so a corrupted byte fails its own row check[1]
  2. An extra parity byte is sent whose bits give the parity of each column across the block[1]
  3. A single flipped bit causes exactly one row and exactly one column to fail their checks[1]
  4. The bit at the intersection of that row and column is the faulty one, so it can simply be flipped back — no resend is neededthe intersection is the key idea[1]

The failing row and failing column intersect at the corrupted bit, which is then flipped back.

Q17[4 marks]
Describe how Automatic Repeat reQuest ensures reliable delivery, including what happens if a packet is lost entirely.
Mark scheme
  1. The receiver checks each packet using an error-detection method such as a checksum[1]
  2. It sends back a positive acknowledgement if the packet is intact, or a negative one if it is corrupted, prompting a resend[1]
  3. The sender starts a timer when it transmits each packet[1]
  4. If no acknowledgement arrives before the timeout, the packet is assumed lost and resent — which covers a packet that never arrived, since the receiver had nothing to checkthe timeout is the mark most often missed[1]

Acknowledgements handle corrupted packets; a timeout handles ones that never arrive.

Q18[6 marks]
A hospital transmits patient records between buildings over a long cable.
  1. Explain two causes of transmission errors over such a link.
  2. Recommend an error-detection method and justify it for this application.
  3. Explain why detection alone is not sufficient here, and what must be added.
Mark scheme
  1. Attenuation — the signal weakens over the distance until a bit is misread[1]
  2. Interference from nearby electrical equipment, which a hospital has a great deal ofaccept skew if parallel[1]
  3. A checksum on each packet, since it detects most corruption across the whole block rather than one byte at a timeaccept parity block with justification[1]
  4. Patient data must be exactly correct — a single wrong digit in a dosage could cause harm — so a strong check is justified even at the cost of extra datathe justification must fit the context[1]
  5. Detection only tells you the data is wrong; it does not deliver the correct data[1]
  6. ARQ must be added so that any packet failing the check, or failing to arrive at all, is automatically requested again until it is received intact[1]

(a) attenuation and interference (b) a checksum, because the data must be exact (c) detection must be paired with ARQ so faulty packets are resent

07

Ethics and Ownership

Multiple choice · 8

Q1Selling users' data in a way disclosed only in clause 47 of long terms is:

  1. Aillegal and unethical
  2. Bpossibly legal but ethically questionable
  3. Clegal and ethical
  4. Dneither
Show answer

Correct answer: B — possibly legal but ethically questionable

Disclosure in the terms may satisfy the law, but consent buried where nobody reads it is not meaningful agreement — the distinction between legal and ethical is exactly the point.

Q2The most reliable defence against ransomware is:

  1. Aantivirus software
  2. Ba strong password
  3. Coffline backups
  4. Dpaying the ransom
Show answer

Correct answer: C — offline backups

A disconnected backup cannot be encrypted, so files can be restored without paying. Paying is unreliable — there is no guarantee a key is supplied.

Q3Phishing works primarily by attacking:

  1. Athe operating system
  2. Bthe network cable
  3. Cthe person
  4. Dthe antivirus
Show answer

Correct answer: C — the person

It relies on deceiving a human into handing over credentials. No software vulnerability is required, which is why training matters as much as technical defences.

Q4Data minimisation means:

  1. Acompressing files
  2. Bcollecting only what is needed for the stated purpose
  3. Cdeleting all data
  4. Dusing small databases
Show answer

Correct answer: B — collecting only what is needed for the stated purpose

It is a privacy principle, not a storage technique. Data never collected cannot be leaked, misused or stolen.

Q5Copyright on a piece of software:

  1. Amust be registered to exist
  2. Bexists automatically when the work is created
  3. Clasts one year
  4. Dapplies only to printed material
Show answer

Correct answer: B — exists automatically when the work is created

Copyright arises automatically on creation. A licence is separate — it states what others are permitted to do with the copyrighted work.

Q6Two-factor authentication protects against:

  1. Aa stolen password being enough to log in
  2. Bviruses
  3. Cslow internet
  4. Dhardware failure
Show answer

Correct answer: A — a stolen password being enough to log in

Even with the correct password, an attacker still needs the second factor — typically a code on the owner's phone.

Q7The digital divide describes:

  1. Athe gap between fast and slow computers
  2. Bthe gap between those with and without access to technology
  3. Cthe split between hardware and software
  4. Ddifferences between operating systems
Show answer

Correct answer: B — the gap between those with and without access to technology

It is about access to devices, connectivity and skills. It matters most when essential services move online and assume everyone can reach them.

Q8Using an image from the internet in your own published work without permission is:

  1. Aalways allowed
  2. Bcopyright infringement unless licensed or permitted
  3. Cplagiarism only
  4. Dlegal if you change it slightly
Show answer

Correct answer: B — copyright infringement unless licensed or permitted

The image is copyrighted from the moment it was created. Altering it slightly does not create a new work you own, and "it was on the internet" is not a licence.

Exam-style questions · 6

Q1[2 marks]
Differentiate between a legal issue and an ethical issue in computing, with an example of each.
Answer

A legal issue concerns what the law permits — for example copying licensed software without paying, which breaches copyright. An ethical issue concerns what is right regardless of the law — for example a company legally selling users' browsing histories to advertisers without making that clear.

Q2[2 marks]
What is phishing, and state one way to recognise it?
Answer

Phishing is an attempt to obtain personal information such as passwords by sending a message that imitates a trusted organisation. Recognise it by checking the sender's actual address and the real destination of any link, and by treating urgency — "your account will be closed today" — as a warning sign rather than a reason to hurry.

Q3[2 marks]
What is meant by the digital divide?
Answer

The digital divide is the gap between people who have reliable access to computers and the internet and those who do not — whether because of cost, location, or lack of skills. It matters because as services move online, those without access are excluded from them.

Q4[4 marks]
State four principles that should govern an organisation's handling of personal data.
Mark scheme
  1. Collect only the data needed for a clearly stated purpose (data minimisation)[1]
  2. Use it only for that stated purpose, and obtain informed consent[1]
  3. Keep it accurate, secure and protected against unauthorised access[1]
  4. Retain it no longer than necessary, and allow individuals to see and correct what is held about them[1]

Minimise, use only for the stated purpose, keep secure and accurate, and delete when done.

Q5[4 marks]
Explain how ransomware works and why offline backups are the most effective protection.
Mark scheme
  1. Ransomware is malware that encrypts the victim's files so they cannot be opened[1]
  2. It then demands payment in exchange for the decryption key, with no guarantee the key will be supplied[1]
  3. It encrypts everything it can reach, including attached backup drives and automatically synchronised cloud foldersthis is why ordinary backups fail[1]
  4. A backup kept disconnected cannot be reached and therefore cannot be encrypted, so the files can be restored without paying[1]

It encrypts files and demands payment; only a disconnected backup is out of its reach.

Q6[6 marks]
A social media company collects users' location data continuously and sells summaries of it to advertisers. Its terms and conditions mention this in clause 47 of a 40-page document.
  1. Explain whether this is a legal issue, an ethical issue, or both.
  2. Explain what "informed consent" would require here.
  3. Describe two harms that could result from this data being leaked.
Mark scheme
  1. It may well be legal, since the practice is disclosed in the terms the user agreed to[1]
  2. But it is ethically questionable, because burying it in clause 47 of a document nobody reads means users have not meaningfully agreedboth categories must be addressed[1]
  3. Informed consent requires the user to be told clearly, in plain language and before agreeing, exactly what is collected and who it is shared with[1]
  4. It must be a genuine choice — the service should not be withheld unless the user agrees to data collection unrelated to providing it[1]
  5. Harm: a continuous location history reveals home and workplace addresses, daily routines and religious or medical visits, enabling stalking or burglary[1]
  6. Harm: it could be used for identity theft, blackmail, or discrimination by employers or insurersany second concrete harm[1]

(a) probably legal but ethically poor (b) plain language, in advance, a genuine choice (c) stalking or burglary from routine data; blackmail or discrimination

08

Databases

Multiple choice · 32

Q1A field that uniquely identifies each record is the:

  1. Aforeign key
  2. Bprimary key
  3. Ccomposite field
  4. Dindex
Show answer

Correct answer: B — primary key

The primary key must be unique and never empty. A foreign key refers to another table's primary key.

Q2ClassID appearing in the STUDENT table, referring to CLASS, is a:

  1. Aprimary key
  2. Bforeign key
  3. Ccandidate key
  4. Dcomposite key
Show answer

Correct answer: B — foreign key

It holds the primary key value of another table, which is exactly what makes it a foreign key and what links the two tables.

Q3A many-to-many relationship is implemented using:

  1. Atwo tables only
  2. Ba third linking table
  3. Ca composite field
  4. Dno keys
Show answer

Correct answer: B — a third linking table

A field holds a single value, so neither side can store a list of the other. The linking table turns it into two one-to-many relationships.

Q4In a one-to-many relationship, the foreign key is placed:

  1. Aon the "one" side
  2. Bon the "many" side
  3. Cin both tables
  4. Din a third table
Show answer

Correct answer: B — on the "many" side

Each record on the many side refers to exactly one record on the one side, which is a single value and therefore fits in a field.

Q5A student's grade in a course should be stored in:

  1. Athe STUDENT table
  2. Bthe COURSE table
  3. Cthe linking ENROLMENT table
  4. Da separate file
Show answer

Correct answer: C — the linking ENROLMENT table

The grade needs both keys to identify it — it belongs to that student in that course, so it is an attribute of the relationship.

Q6Which is the best primary key for a student record?

  1. AFull name
  2. BDate of birth
  3. CAn auto-generated roll number
  4. DHome address
Show answer

Correct answer: C — An auto-generated roll number

It is guaranteed unique and has no reason ever to change. Names repeat, dates of birth repeat, and addresses change.

Q7Concurrency control exists to:

  1. Aspeed up queries
  2. Bstop simultaneous updates corrupting data
  3. Ccompress the database
  4. Dencrypt records
Show answer

Correct answer: B — stop simultaneous updates corrupting data

Without it, two users saving changes to the same record at the same moment can leave the data in an inconsistent state or lose one update entirely.

Q8A composite primary key is needed when:

  1. Athe table is large
  2. Bno single field is unique
  3. Cthere are two tables
  4. Dforeign keys are used
Show answer

Correct answer: B — no single field is unique

In an ENROLMENT table neither StudentID nor CourseID is unique alone, but the pair together identifies exactly one enrolment.

Q9Which design stage depends on the DBMS chosen?

  1. AConceptual
  2. BLogical
  3. CPhysical
  4. DNone
Show answer

Correct answer: C — Physical

Data types, indexes and storage differ between products. The conceptual and logical designs are deliberately product-independent.

Q10In a description, nouns are most likely to be:

  1. Arelationships
  2. Bentities and attributes
  3. Cprimary keys
  4. Dqueries
Show answer

Correct answer: B — entities and attributes

Nouns name things; verbs describe how they relate. Sorting nouns into entities and attributes is the next step.

Q11"One student takes many subjects; one subject has many students" is:

  1. A1:1
  2. B1:M
  3. CM:N
  4. Dnot a relationship
Show answer

Correct answer: C — M:N

Both directions are "many", so it is many-to-many and requires a linking table.

Q12"One doctor has many appointments; one appointment has one doctor" is:

  1. A1:1
  2. B1:M
  3. CM:N
  4. Dundefined
Show answer

Correct answer: B — 1:M

One direction is many and the other is one. This becomes a foreign key on the appointment table.

Q13An M:N relationship requires:

  1. Aa foreign key on either side
  2. Ba linking table
  3. Ca composite field
  4. Dno keys
Show answer

Correct answer: B — a linking table

A field can hold only one value, so neither side can reference many rows on the other. The linking table turns it into two 1:M relationships.

Q14A noun should be modelled as an entity when it:

  1. Aappears more than once
  2. Bhas properties of its own to store
  3. Cis capitalised
  4. Dis in the first sentence
Show answer

Correct answer: B — has properties of its own to store

If the only thing you store about it is the value itself, it is an attribute. If it has its own attributes, it needs its own table.

Q15The date of an appointment belongs in:

  1. Athe PATIENT table
  2. Bthe DOCTOR table
  3. Cthe APPOINTMENT table
  4. Dall three
Show answer

Correct answer: C — the APPOINTMENT table

It describes that meeting, not the patient or the doctor, both of whom have many appointments on different dates.

Q16Designing directly in the software rather than on paper usually leads to:

  1. Afaster development with no drawbacks
  2. Ba structure that becomes hard to change
  3. Cbetter normalisation
  4. Dfewer tables
Show answer

Correct answer: B — a structure that becomes hard to change

Decisions get made implicitly and are then embedded in forms, queries and reports. Changing the structure afterwards means changing all of them.

Q17A rule that a mark must be between 0 and 100 is a:

  1. Apresence check
  2. Brange check
  3. Cformat check
  4. Dverification
Show answer

Correct answer: B — range check

It tests whether the value lies within allowed limits, which is exactly what a range check does.

Q18A date of birth typed as 1995 instead of 1985 would be caught by:

  1. Avalidation
  2. Bverification
  3. Ca range check
  4. Da type check
Show answer

Correct answer: B — verification

1995 is a perfectly reasonable date, so it passes every validation rule. Only checking it against the source — verification — reveals the error.

Q19Preventing a class from being deleted while students still refer to it is:

  1. Aentity integrity
  2. Breferential integrity
  3. Cdomain integrity
  4. Dnormalisation
Show answer

Correct answer: B — referential integrity

Referential integrity ensures foreign keys always point at records that exist, so deleting the referenced record is refused or cascaded.

Q20A table with a column holding "Maths, Physics" is not in:

  1. A1NF
  2. B2NF
  3. C3NF
  4. Dany normal form problem
Show answer

Correct answer: A — 1NF

A cell containing more than one value is a repeating group, which 1NF forbids. Later forms cannot even be assessed until this is fixed.

Q21A dependency on part of a composite key is a:

  1. Atransitive dependency
  2. Bpartial dependency
  3. Creferential constraint
  4. Dforeign key
Show answer

Correct answer: B — partial dependency

Partial dependencies are removed at 2NF. They can only exist where the primary key is made of more than one field.

Q22In STUDENT(RollNo, Name, ClassID, ClassTeacher), ClassTeacher depending on ClassID is a:

  1. Apartial dependency
  2. Btransitive dependency
  3. Cvalid design
  4. Dcomposite key
Show answer

Correct answer: B — transitive dependency

RollNo → ClassID → ClassTeacher is a chain through a non-key field, which 3NF removes by splitting out a CLASS table.

Q23Having to change a customer name in fifty rows is an:

  1. Ainsertion anomaly
  2. Bdeletion anomaly
  3. Cupdate anomaly
  4. Dintegrity constraint
Show answer

Correct answer: C — update anomaly

One fact stored in fifty places means fifty edits, and missing one leaves the database holding two different names for the same customer.

Q24One genuine cost of normalising a database is:

  1. Amore storage used
  2. Bqueries need joins across more tables
  3. Cdata becomes inconsistent
  4. Dkeys are lost
Show answer

Correct answer: B — queries need joins across more tables

Normalisation reduces storage and removes inconsistency. What it costs is query complexity — assembling a full record now means joining several tables.

Q25CREATE TABLE is an example of:

  1. ADML
  2. BDDL
  3. Ca query
  4. Dan aggregate
Show answer

Correct answer: B — DDL

It defines structure rather than manipulating data, so it belongs to the Data Definition Language.

Q26Which clause filters rows before any grouping takes place?

  1. AHAVING
  2. BWHERE
  3. CGROUP BY
  4. DORDER BY
Show answer

Correct answer: B — WHERE

WHERE is applied to individual rows first. HAVING acts on groups after aggregation.

Q27To show only groups whose total exceeds 100, you use:

  1. AWHERE SUM(x) > 100
  2. BHAVING SUM(x) > 100
  3. CORDER BY SUM(x)
  4. DSELECT SUM(x) > 100
Show answer

Correct answer: B — HAVING SUM(x) > 100

A condition on an aggregate must come after grouping, which is what HAVING does.

Q28Which is NOT an aggregate function?

  1. ACOUNT
  2. BAVG
  3. CORDER
  4. DMAX
Show answer

Correct answer: C — ORDER

ORDER BY sorts the output; it does not compute a value across a group.

Q29UPDATE Employee SET Salary = 0; will:

  1. Achange nothing
  2. Bchange one row
  3. Cchange every row
  4. Dcause a syntax error
Show answer

Correct answer: C — change every row

With no WHERE clause every row matches, so the whole table is updated. This is the classic destructive mistake.

Q30DROP TABLE Student differs from DELETE FROM Student because it:

  1. Ais faster
  2. Bremoves the table structure as well
  3. Conly removes some rows
  4. Dneeds a WHERE clause
Show answer

Correct answer: B — removes the table structure as well

DELETE empties the table but leaves it usable; DROP removes the table entirely.

Q31A FOREIGN KEY constraint ensures that:

  1. Avalues are unique
  2. Ba referenced row actually exists
  3. Cthe column is never null
  4. Drows are sorted
Show answer

Correct answer: B — a referenced row actually exists

It enforces referential integrity, preventing a reference to a key that is not present in the other table.

Q32WHERE Surname LIKE 'Kh%' matches:

  1. Aexactly "Kh"
  2. Banything ending in Kh
  3. Canything starting with Kh
  4. Danything containing Kh
Show answer

Correct answer: C — anything starting with Kh

The % wildcard stands for any sequence of characters following, so the pattern anchors at the start.

Exam-style questions · 23

Q1[2 marks]
Define a primary key and state two properties it must have.
Answer

A primary key is a field, or combination of fields, that uniquely identifies each record in a table. It must be unique across all records and must never be empty. It should also never change.

Q2[2 marks]
What is a foreign key?
Answer

A field in one table that holds the primary key value of another table, creating the link between them. For example, ClassID stored in the STUDENT table refers to the primary key of the CLASS table.

Q3[2 marks]
Why is a student's name unsuitable as a primary key?
Answer

Names are not unique — two students may share one — and they can change, which would break every foreign key referring to that record. A primary key should be a meaningless, stable identifier such as a roll number.

Q4[4 marks]
State four services provided by a database management system.
Mark scheme
  1. Data integrity — validation rules and constraints reject invalid data[1]
  2. Security — access permissions per user, per table, or per field[1]
  3. Concurrency control — simultaneous updates by different users cannot corrupt the data[1]
  4. Backup and recovery, and a query language for answering unanticipated questionseither earns the mark[1]

Integrity, security, concurrency control, backup and recovery, and a query language.

Q5[4 marks]
A driving school records instructors and students. Each student is taught by one instructor; each instructor teaches many students. Design the tables, identifying keys.
Mark scheme
  1. Relationship identified as one to many, from instructor to student[1]
  2. INSTRUCTOR(InstructorID, Name, Phone)primary key underlined or stated[1]
  3. STUDENT(StudentID, Name, Address, InstructorID)[1]
  4. InstructorID in STUDENT is a foreign key referring to INSTRUCTOR — the key goes on the "many" sideplacing it on the wrong side is the standard error[1]

Two tables, with InstructorID as a foreign key in STUDENT.

Q6[6 marks]
A college needs a database recording which students are enrolled in which courses, and the grade each student achieved in each course.
  1. Identify the relationship between STUDENT and COURSE and explain why it cannot be stored in two tables.
  2. Design the tables, showing primary and foreign keys.
  3. Explain where the grade must be stored and why.
Mark scheme
  1. Many to many — a student takes many courses and a course has many students[1]
  2. A field holds a single value, so neither table can hold a list of the other; a third table is requiredthe reason, not just the assertion[1]
  3. STUDENT(StudentID, Name) and COURSE(CourseID, Title)[1]
  4. ENROLMENT(StudentID, CourseID, Grade) with a composite primary key, both fields also being foreign keysaccept a separate EnrolmentID[1]
  5. The grade belongs in ENROLMENT[1]
  6. Because it is a property of that particular student's enrolment in that particular course — not of the student, who has many grades, nor of the course, which awards manythe reasoning is the mark[1]

(a) many to many — a field cannot hold a list (b) STUDENT, COURSE and an ENROLMENT linking table (c) the grade goes in ENROLMENT, since it belongs to the relationship

Q7[2 marks]
Name the three stages of database design.
Answer

Conceptual design — identifying entities, attributes and relationships. Logical design — converting these to tables with keys and normalising them. Physical design — choosing data types, indexes and storage for the particular DBMS.

Q8[2 marks]
How do you decide whether a noun in a description is an entity or an attribute?
Answer

A noun with properties of its own that must be stored is an entity and becomes a table. A noun that is simply a single property of something else is an attribute and becomes a field. "Address" is usually an attribute of a customer, but becomes an entity if the system must store a district, postcode and access notes for each one.

Q9[2 marks]
What does cardinality mean in an ER diagram?
Answer

The number of records on each side of a relationship that may be associated with one record on the other — written 1:1, 1:M or M:N. It determines the table structure, since a 1:M becomes a foreign key while an M:N requires an additional linking table.

Q10[4 marks]
From this description, identify the entities and the relationship: "A bookshop stocks many titles. Each title is supplied by one publisher, and a publisher supplies many titles."
Mark scheme
  1. Entities: TITLE and PUBLISHERbookshop is the system, not an entity[1]
  2. Relationship: one publisher supplies many titles, and each title has one publisher — 1:Mstated in both directions[1]
  3. PUBLISHER(PublisherID, Name, Address)[1]
  4. TITLE(ISBN, Title, Price, PublisherID) — the foreign key on the many sideISBN is a natural primary key here[1]

TITLE and PUBLISHER, in a 1:M relationship, with PublisherID as a foreign key in TITLE.

Q11[4 marks]
Explain why an M:N relationship cannot be implemented with two tables, and describe how it is resolved.
Mark scheme
  1. A field holds a single value, so it cannot store a list of related recordsthe fundamental reason[1]
  2. Putting a foreign key on either side would allow only one match, which contradicts "many"[1]
  3. A third linking table is created, containing the primary keys of both entities as foreign keys[1]
  4. This converts the M:N into two 1:M relationships, each of which tables can express; the linking table also holds any attribute of the relationship itself[1]

A field holds one value, so a linking table with both foreign keys is required, giving two 1:M relationships.

Q12[6 marks]
A gym records members, the classes it runs, and which members attend which classes. Each class is taught by one instructor.
  1. Identify the entities.
  2. State each relationship with its cardinality.
  3. Give the tables with their primary and foreign keys.
Mark scheme
  1. Entities: MEMBER, CLASS, INSTRUCTORgym is the system itself[1]
  2. INSTRUCTOR to CLASS is 1:M — one instructor teaches many classes, each class has one instructor[1]
  3. MEMBER to CLASS is M:N — a member attends many classes and a class has many membersstated in both directions[1]
  4. INSTRUCTOR(InstructorID, Name) and CLASS(ClassID, ClassName, Time, InstructorID)InstructorID is the foreign key on the many side[1]
  5. MEMBER(MemberID, Name, JoinDate)[1]
  6. ATTENDANCE(MemberID, ClassID, Date) — a linking table with a composite key, resolving the M:NDate belongs here, being a property of that attendance[1]

(a) MEMBER, CLASS, INSTRUCTOR (b) instructor–class 1:M, member–class M:N (c) four tables, with ATTENDANCE linking members to classes

Q13[2 marks]
Differentiate between validation and verification.
Answer

Validation is an automatic check that entered data is reasonable — within range, of the right type, in the right format. Verification checks that the data was entered correctly, for example by double entry or by reading it back. A date typed as 1995 instead of 1985 passes validation but fails verification.

Q14[2 marks]
What is referential integrity?
Answer

The rule that a foreign key must either be empty or match an existing primary key in the related table. It prevents orphaned records — a student enrolled in a class that does not exist, or left pointing at a class after it is deleted.

Q15[2 marks]
A table is in 1NF. What must be true of it?
Answer

It contains no repeating groups — every cell holds a single, indivisible value, and there are no columns such as Subject1, Subject2, Subject3. Every record is also uniquely identifiable by a primary key.

Q16[4 marks]
Explain the three anomalies that normalisation removes, with an example of each.
Mark scheme
  1. Insertion anomaly — a fact cannot be recorded without another. A new teacher cannot be entered until a student enrols with them[1]
  2. Deletion anomaly — removing one fact destroys another. Deleting the last enrolment erases the teacher's phone number[1]
  3. Update anomaly — one change must be made in many rows[1]
  4. Missing one row leaves the database holding two different values for the same fact, so no report can be trustedthe consequence is the fourth mark[1]

Insertion, deletion and update anomalies, all caused by storing a fact in more than one row.

Q17[4 marks]
The table STUDENT(RollNo, Name, ClassID, ClassTeacher) is in 2NF but not 3NF. Explain why and correct it.
Mark scheme
  1. ClassTeacher depends on ClassID, not on the primary key RollNo[1]
  2. RollNo → ClassID → ClassTeacher is a transitive dependency through a non-key field, which 3NF forbidsnaming it is required[1]
  3. Split into STUDENT(RollNo, Name, ClassID)ClassID remains as a foreign key[1]
  4. and CLASS(ClassID, ClassTeacher) — the teacher is now stored once per class[1]

A transitive dependency; split into STUDENT and CLASS tables.

Q18[6 marks]
A table records library loans: LOAN(LoanID, MemberID, MemberName, BookISBN, BookTitle, Author, DateOut).
  1. Identify two problems with this structure.
  2. Normalise it to 3NF, showing all tables and keys.
  3. Explain one benefit and one cost of the normalised design.
Mark scheme
  1. MemberName is repeated on every loan by that member, and BookTitle and Author on every loan of that book — redundancy[1]
  2. An update anomaly follows: correcting a member's name means editing every one of their loan records, and missing one leaves contradictory dataaccept insertion: a new book cannot be recorded until it is borrowed[1]
  3. MEMBER(MemberID, MemberName)[1]
  4. BOOK(BookISBN, BookTitle, Author)[1]
  5. LOAN(LoanID, MemberID, BookISBN, DateOut) — both foreign keys, and DateOut belongs to the loan itself[1]
  6. Benefit: each fact is stored once, so updates are single edits and no contradiction is possible. Cost: retrieving a full loan report now requires joining three tables, which is more complex and slower to queryboth halves needed for the mark[1]

(a) redundancy and update anomalies (b) MEMBER, BOOK and LOAN (c) single-point updates, at the cost of joins

Q19[2 marks]
State the difference between DDL and DML, giving one command from each.
Answer

DDL defines or alters the structure of the database — for example CREATE TABLE. DML operates on the data held in the rows — for example SELECT or INSERT.

Q20[2 marks]
Explain why WHERE COUNT(*) > 5 is not valid, and state what should be used instead.
Answer

WHERE is applied to individual rows before grouping, so at that point no counting has taken place and there is nothing to compare. A condition on an aggregate must appear in a HAVING clause, which is applied to the groups after aggregation.

Q21[3 marks]
Write an SQL statement to create a table Book with fields ISBN (primary key), Title (text, required) and YearPublished (integer).
Answer

CREATE TABLE Book (ISBN VARCHAR(13) PRIMARY KEY, Title VARCHAR(100) NOT NULL, YearPublished INTEGER);

Q22[6 marks]
A database has Employee(EmpID, Name, DeptID, Salary) and Department(DeptID, DeptName).
(a) Write a query listing the names of employees earning more than 50000, alphabetically.
(b) Write a query giving each department name and its average salary.
(c) Modify (b) to show only departments whose average salary exceeds 40000.
(d) State what happens if an UPDATE statement is run without a WHERE clause.
Mark scheme
  1. (a) SELECT Name FROM Employee WHERE Salary > 50000 ORDER BY Name;A condition on a plain column belongs in WHERE.[1]
  2. ORDER BY Name gives alphabetical order (ASC is the default).The ordering clause is a separate mark.[1]
  3. (b) SELECT Department.DeptName, AVG(Salary) FROM Employee JOIN Department ON Employee.DeptID = Department.DeptIDThe join is needed because the two pieces of information sit in different tables.[1]
  4. GROUP BY Department.DeptName;Grouping is what produces one row per department.[1]
  5. (c) Add HAVING AVG(Salary) > 40000 after the GROUP BY clause.An aggregate condition, so HAVING rather than WHERE.[1]
  6. (d) Every row in the table is updated, because there is no condition restricting which rows match.The consequence must be stated as affecting all rows.[1]

(a) WHERE + ORDER BY; (b) JOIN + GROUP BY; (c) HAVING; (d) every row is changed

Q23[2 marks]
State the difference between DELETE FROM Student; and DROP TABLE Student;
Answer

DELETE FROM Student; removes every row but leaves the table structure in place, so it can still be used. DROP TABLE Student; removes the table itself — structure and data — so it no longer exists.

09

Algorithm Design and Problem-solving

Multiple choice · 14

Q1Breaking a large problem into smaller parts is called:

  1. Aabstraction
  2. Bdecomposition
  3. Citeration
  4. Dvalidation
Show answer

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?

  1. ARectangle
  2. BParallelogram
  3. CDiamond
  4. DRounded box
Show answer

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:

  1. Auses few steps
  2. Balways stops
  3. Cfits on one page
  4. Dhas one input
Show answer

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:

  1. Adecomposition
  2. Babstraction
  3. Can algorithm
  4. Dvalidation
Show answer

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:

  1. A30 and 40
  2. B18 and 65
  3. Cabc and −1
  4. D100 only
Show answer

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:

  1. Ais acceptable
  2. Bdoes not show the direction of flow and loses a mark
  3. Cmeans a loop
  4. Dindicates an error
Show answer

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?

  1. Ainside the loop
  2. Bafter the loop
  3. Cbefore the loop
  4. Dit does not matter
Show answer

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:

  1. Adraw a flowchart
  2. Bfollow an algorithm by hand and find logic errors
  3. Ccompile a program
  4. Dmeasure execution speed
Show answer

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?

  1. AO(5n + 300)
  2. BO(n)
  3. CO(300)
  4. DO(n²)
Show answer

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?

  1. A1,000,000
  2. B1,000
  3. C20
  4. D2
Show answer

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?

  1. ASelection sort
  2. BInsertion sort
  3. CBubble sort with no early exit
  4. DAll are identical
Show answer

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²)?

  1. AWhen the array contains duplicates
  2. BWhen the pivot repeatedly splits the array very unevenly
  3. CWhen n is a prime number
  4. DIt never degrades
Show answer

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?

  1. AIt uses too much memory
  2. BEvery extra input element doubles the total work
  3. CIt only works on sorted data
  4. DIt requires recursion
Show answer

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?

  1. ABig-O is wrong here
  2. BNothing — Big-O describes growth rate, not absolute speed
  3. CThey must have different complexities
  4. DThe 10-second one is really O(n²)
Show answer

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.

Exam-style questions · 12

Q1[2 marks]
Define an algorithm.
Answer

A finite sequence of unambiguous instructions that solves a problem or completes a task, with clearly defined inputs and outputs.

Q2[2 marks]
Explain what is meant by abstraction, with an example.
Answer

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.

Q3[2 marks]
State two differences between a flowchart and pseudocode.
Answer

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.

Q4[4 marks]
Write an algorithm in pseudocode that reads a student's marks out of 100 and prints "Pass" if the mark is 40 or more and "Fail" otherwise. Include validation that rejects marks outside 0–100.
Mark scheme
  1. INPUT mark[1]
  2. Validation: 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]
  3. IF mark >= 40 THEN OUTPUT "Pass"the >= is required; > alone fails a mark of exactly 40[1]
  4. ELSE OUTPUT "Fail" ENDIF[1]

Input with a validation loop, then IF mark >= 40 output Pass ELSE output Fail.

Q5[4 marks]
Complete a trace table for this algorithm with input 4: SET total = 0; SET i = 1; WHILE i <= n DO total = total + i; i = i + 1; ENDWHILE; OUTPUT total
Mark scheme
  1. Columns for n, i, total, and outputone column per variable[1]
  2. After pass 1: i = 2, total = 1; after pass 2: i = 3, total = 3[1]
  3. After pass 3: i = 4, total = 6; after pass 4: i = 5, total = 10[1]
  4. The loop ends because 5 > 4; output is 10the algorithm sums 1 to n[1]

Output 10 — the algorithm computes 1 + 2 + 3 + 4.

Q6[6 marks]
A school wants a program that records attendance for every class each day and produces a monthly report.
  1. Describe how decomposition would be applied to this problem.
  2. Give one example of abstraction in this system.
  3. Explain why the algorithm should be tested with boundary data, giving one example of such data.
Mark scheme
  1. Break the system into separate sub-problems, such as: record one student's attendance; store a day's records; calculate one student's monthly totalat least two named sub-problems[1]
  2. And: produce the report; handle login. Each is small enough to be designed and tested on its ownthe reason for decomposing is part of the answer[1]
  3. Abstraction: store only what the task needs — a student's roll number and present/absent flag — and ignore irrelevant details such as their address or hobbies[1]
  4. The unnecessary detail would make the system larger and slower without improving the report[1]
  5. Boundary data tests the values at the edges of what is acceptable, which is where most errors occur[1]
  6. Example: a month with 31 days, or a class with exactly one student, or an attendance percentage of exactly 75% if that is the pass thresholdany sensible boundary value[1]

(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

Q7[2 marks]
State one condition that must be met before a binary search can be used, and state why.
Answer

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.

Q8[2 marks]
Explain what is meant by the time complexity of an algorithm.
Answer

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.

Q9[3 marks]
A linear search of 1000 items takes at most 1000 comparisons. State the maximum number a binary search would need, and explain.
Answer

About 10, because 2¹⁰ = 1024. Each comparison halves the remaining list, so the maximum is log₂ n rounded up.

Q10[7 marks]
A bubble sort is used on the list 5, 3, 8, 1.
  1. Write out the list after each complete pass. [3]
  2. State the total number of passes needed and explain how the algorithm knows it has finished. [2]
  3. State the time complexity of a bubble sort and explain why it is unsuitable for large data sets. [2]
Mark scheme
  1. After pass 1: 3, 5, 1, 8[1]
  2. After pass 2: 3, 1, 5, 8[1]
  3. After pass 3: 1, 3, 5, 8[1]
  4. Three passes; a fourth confirms no swaps[1]
  5. A flag records whether any swap was made; if a whole pass makes none, the list is sorted[1]
  6. O(n²)[1]
  7. Doubling the data quadruples the work, so it becomes impractically slow[1]
Q11[8 marks]
A program must find whether a student name appears in a sorted list of 5000 names.
  1. Write pseudocode for a binary search on this list. [5]
  2. Explain what your code returns when the name is not present. [1]
  3. Compare the number of comparisons with a linear search on the same list. [2]
Mark scheme
  1. Initialises low = 1 and high = 5000[1]
  2. Loops while low <= high[1]
  3. Calculates mid = (low + high) DIV 2[1]
  4. Compares and returns mid if the name matches[1]
  5. Otherwise sets high = mid − 1 or low = mid + 1 correctly[1]
  6. Returns a value such as −1 or FALSE once low > high[1]
  7. Binary search: at most 13 comparisons, since 2¹³ = 8192[1]
  8. Linear search: up to 5000, so binary search is dramatically faster[1]
Q12[5 marks]
An algorithm is described as having complexity O(n log n).
  1. Name one sorting algorithm with this complexity. [1]
  2. Explain why it scales better than O(n²) as n grows. [2]
  3. A data set of 1000 items takes 2 seconds with the O(n log n) algorithm. Estimate the time for 2000 items and justify your estimate. [2]
Mark scheme
  1. Merge sort or quicksort (average case)[1]
  2. The log n factor grows very slowly compared with the extra factor of n[1]
  3. So the gap between the two widens rapidly as n increases[1]
  4. Doubling n slightly more than doubles n log n[1]
  5. So roughly 4.2 to 4.5 seconds, a little over doubleaccept "just over 4 seconds" with reasoning[1]
10

Data Types and Structures

Multiple choice · 22

Q1All the details of one student form a:

  1. Afield
  2. Brecord
  3. Ctable
  4. Ddatabase
Show answer

Correct answer: B — record

A record is every field describing one entity. A field is one of those items; a table is many records.

Q2A student's roll number should be stored as:

  1. Ainteger
  2. Btext
  3. Cdecimal
  4. Dboolean
Show answer

Correct answer: B — text

No arithmetic is done on a roll number, and it may have leading zeros or letters. The test is always whether you would ever add two of them.

Q3The same address stored in three files is an example of:

  1. Anormalisation
  2. Bdata redundancy
  3. Ca primary key
  4. Da query
Show answer

Correct answer: B — data redundancy

Redundancy is duplication. Its dangerous consequence is inconsistency, when the copies stop agreeing.

Q4Which is the most serious consequence of redundancy?

  1. Awasted disk space
  2. Binconsistent conflicting values
  3. Cslower typing
  4. Dlarger backups
Show answer

Correct answer: B — inconsistent conflicting values

Storage is cheap. Conflicting values mean no report can be trusted, because there is no way to tell which copy is correct.

Q5Data dependence means:

  1. Adata depends on other data
  2. Bprograms contain the file structure, so structural changes require rewriting them
  3. Cfields depend on records
  4. Dthe database needs internet
Show answer

Correct answer: B — programs contain the file structure, so structural changes require rewriting them

Each program embeds the layout of the file it reads, so adding a single field means editing and retesting every one of them.

Q6A price of Rs 249.99 is best stored as:

  1. Atext
  2. Binteger
  3. Ccurrency or decimal
  4. Dboolean
Show answer

Correct answer: C — currency or decimal

It has a fractional part and arithmetic will be done on it. A currency or fixed-decimal type also avoids the rounding errors a floating-point type can introduce in money.

Q7Storing a date as text causes problems because:

  1. Ait uses more space
  2. Bit sorts alphabetically rather than chronologically
  3. Cdates cannot be text
  4. Dit needs more fields
Show answer

Correct answer: B — it sorts alphabetically rather than chronologically

As text, "01/12/2025" sorts before "02/01/2024", so the system cannot determine which date came first or calculate an interval.

Q8A database centralises data, which means an incorrectly typed address is now:

  1. Aautomatically corrected
  2. Bwrong in every system at once
  3. Cstored three times
  4. Dignored
Show answer

Correct answer: B — wrong in every system at once

Centralisation removes inconsistency but also removes the accidental second opinion. Validation at the point of entry becomes more important, not less.

Q9Why can an array reach element 500 instantly while a linked list cannot?

  1. AArrays are stored in faster memory
  2. BArray elements are contiguous, so the address can be computed arithmetically
  3. CLinked lists are always longer
  4. DArrays keep a separate index table
Show answer

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.

Q10You need to add and remove items constantly at the front of a collection. Which structure fits best?

  1. AArray
  2. BLinked list
  3. CBinary search tree
  4. DHash table
Show answer

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.

Q11A stack is LIFO. Which real situation matches it?

  1. ACustomers waiting at a bank counter
  2. BUndo history in a text editor
  3. CPrint jobs on a shared printer
  4. DCars passing through a tunnel
Show answer

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.

Q12An in-order traversal of a binary search tree outputs the values in what order?

  1. ARandom order
  2. BAscending sorted order
  3. CLevel by level
  4. DReverse insertion order
Show answer

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.

Q13Inserting already-sorted data into a plain binary search tree causes what problem?

  1. AThe tree runs out of memory
  2. BThe tree degenerates into a linked list and search becomes O(n)
  3. CThe values get stored in the wrong order
  4. DNothing — the tree self-balances
Show answer

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.

Q14Breadth-first search needs which helper structure?

  1. AA stack
  2. BA queue
  3. CA hash table
  4. DAn array of size n²
Show answer

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.

Q15Opening an existing file with mode "w":

  1. Aappends to it
  2. Berases its contents
  3. Cfails with NULL
  4. Dopens it read-only
Show answer

Correct answer: B — erases its contents

It truncates the file to zero length at the moment of opening, before anything has been written.

Q16To add a record without losing existing ones, use mode:

  1. A"r"
  2. B"w"
  3. C"a"
  4. D"x"
Show answer

Correct answer: C — "a"

Append preserves the contents and writes at the end. "w" would destroy every previous record.

Q17fopen returns NULL when:

  1. Athe file is empty
  2. Bthe file cannot be opened
  3. Cthe file is large
  4. Dreading succeeds
Show answer

Correct answer: B — the file cannot be opened

It may be missing, locked, or in a location you lack permission for. Using the NULL pointer afterwards crashes the program.

Q18Which is the file version of printf?

  1. Afput
  2. Bfprintf
  3. Cwritef
  4. Dprintfile
Show answer

Correct answer: B — fprintf

It takes the file pointer as its first argument and is otherwise identical in use.

Q19while (!feof(fp)) typically causes:

  1. Aan infinite loop
  2. Bthe last record to be processed twice
  3. Ca compile error
  4. Dthe file to be erased
Show answer

Correct answer: B — the last record to be processed twice

feof only becomes true after a read has already failed, so the body executes once more using the values from the previous successful read.

Q20The reliable way to loop until the end of a file is to:

  1. Acount the lines first
  2. Btest the return value of the read
  3. Cuse feof
  4. Dread the file twice
Show answer

Correct answer: B — test the return value of the read

The read itself reports how many items it obtained, so the loop ends exactly when a read fails rather than one pass later.

Q21Omitting fclose after writing may result in:

  1. Anothing at all
  2. Bbuffered data never reaching the disk
  3. Cthe file being deleted
  4. Da compile error
Show answer

Correct answer: B — buffered data never reaching the disk

Writes are buffered for speed. fclose flushes the buffer, and without it the most recent data may be lost when the program ends.

Q22A file pointer is declared as:

  1. Aint fp;
  2. BFILE *fp;
  3. Cchar fp[];
  4. Dfile fp;
Show answer

Correct answer: B — FILE *fp;

FILE is a type defined in stdio.h, and fopen returns a pointer to it.

Exam-style questions · 18

Q1[2 marks]
Define a field, a record and a table.
Answer

A field is a single item of data, such as a student's name. A record is the complete set of fields describing one entity — all the details of one student. A table is a collection of records of the same type.

Q2[2 marks]
Why should a telephone number be stored as text rather than as a number?
Answer

A numeric type would discard a leading zero, could not store spaces or dashes, and might round the value. No arithmetic is ever performed on a telephone number, so nothing is gained by making it numeric.

Q3[2 marks]
What is data redundancy, and why is data inconsistency worse?
Answer

Redundancy is the same data stored in more than one place. Inconsistency is what happens when one copy is updated and another is not, so the system holds conflicting values. Redundancy wastes storage, which is cheap; inconsistency means no report can be trusted, because there is no way to tell which copy is correct.

Q4[4 marks]
State four disadvantages of storing data in separate flat files rather than a database.
Mark scheme
  1. Redundancy — the same data is duplicated across several files[1]
  2. Inconsistency — updating one copy and not another leaves conflicting values[1]
  3. Data dependence — the file layout is embedded in each program, so a change to the structure means editing every program[1]
  4. Poor security and sharing — access is all-or-nothing per file; also accept difficulty answering unanticipated queries[1]

Redundancy, inconsistency, data dependence, and poor security or difficult queries.

Q5[4 marks]
A shop records sales. State a suitable data type for each field and justify two of your choices: ProductCode, Quantity, Price, DateSold.
Mark scheme
  1. ProductCode — text, since it may contain letters and leading zeros and is never used in arithmetic[1]
  2. Quantity — integer, since you cannot sell a fraction of an item and it is counted[1]
  3. Price — decimal or currency, since it has a fractional part and must keep exact precisiona float can introduce rounding errors in money[1]
  4. DateSold — date, so that date arithmetic and sorting work correctly, which they would not on text[1]

Text, integer, currency, date — each justified by what will be done with it.

Q6[6 marks]
A hospital currently keeps patient details in three separate systems: reception, pharmacy and billing.
  1. Explain two problems this causes.
  2. Explain how a single database would address them.
  3. State one problem a database does NOT solve.
Mark scheme
  1. Redundancy — each patient's name, address and identifier are stored three times[1]
  2. Inconsistency — a change of address entered at reception does not reach pharmacy or billing, so the systems disagree and nobody knows which is rightin a hospital this can affect care, not just correspondence[1]
  3. A database stores each patient record once, so there is only one copy to update and no second copy to disagree with[1]
  4. All three departments read the same record, so a change is visible everywhere immediately[1]
  5. Permissions can be set per table or per field, so pharmacy sees prescriptions and billing does notbetter than all-or-nothing file access[1]
  6. A database does not fix incorrect data entry — if the address is typed wrongly it is now wrong everywhere at once, so validation at entry is still essentialthe honest limitation[1]

(a) redundancy and inconsistency (b) one stored copy, seen by all, with per-table permissions (c) it cannot prevent wrong data being entered — and now the error is everywhere

Q7[2 marks]
State one advantage and one disadvantage of an array compared with a linked list.
Answer

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.

Q8[2 marks]
Explain the difference between a stack and a queue.
Answer

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.

Q9[3 marks]
A stack is implemented with an array and a pointer. Describe what happens to the pointer during a push and during a pop.
Answer

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.

Q10[6 marks]
A program uses a queue to hold print jobs waiting for a printer.
  1. Explain why a queue is the appropriate structure for this task. [2]
  2. Describe how a circular queue avoids the problem of a linear queue in a fixed-size array. [3]
  3. State what must be checked before a job is added. [1]
Mark scheme
  1. Jobs must be printed in the order they were submitted[1]
  2. A queue removes items in the same order they were added, which is first-in-first-out[1]
  3. In a linear queue the front pointer moves forward and the space behind it is wasted[1]
  4. A circular queue wraps the rear pointer round to the start of the array[1]
  5. So the freed space is reused and the array does not appear full while space remains[1]
  6. That the queue is not full[1]
Q11[7 marks]
A binary search tree is built by inserting the values 50, 30, 70, 20, 40, 60 in that order.
  1. Draw the resulting tree. [3]
  2. Write down the in-order traversal. [2]
  3. State what the in-order traversal of any binary search tree always produces, and give one use of that property. [2]
Mark scheme
  1. 50 at the root with 30 on its left and 70 on its right[1]
  2. 20 and 40 as the children of 30[1]
  3. 60 as the left child of 70[1]
  4. Visits left subtree, then node, then right subtree[1]
  5. 20, 30, 40, 50, 60, 70[1]
  6. The values in ascending order[1]
  7. It can therefore be used to sort the data, or to output it in order without re-sorting[1]

(b) 20, 30, 40, 50, 60, 70

Q12[5 marks]
A linked list stores the names Ali, Bilal, Danish in alphabetical order. Each node holds a name and a pointer.
  1. Describe the steps needed to insert Chand in the correct position. [3]
  2. Explain why no data has to be moved, unlike in an array. [2]
Mark scheme
  1. Traverse from the head until the node after which Chand belongs is found, here Bilal[1]
  2. Create the new node and set its pointer to whatever Bilal was pointing at, that is Danish[1]
  3. Set Bilal's pointer to the new nodethis order matters or the rest of the list is lost[1]
  4. The nodes are not stored in consecutive memory locations[1]
  5. Order is held by the pointers, so changing two pointers is enough[1]
Q13[2 marks]
Why are files needed when a program already has variables?
Answer

Variables are held in RAM, which is volatile — their contents are lost the moment the program ends or the power fails. A file is stored on secondary storage, so the data persists and can be read by the same program on another day or by a different program entirely.

Q14[2 marks]
What does fopen return if it fails, and why must this be checked?
Answer

It returns NULL. Using a NULL file pointer in any subsequent read or write causes the program to crash, so the check turns an unexplained failure into a clear message such as "cannot open file".

Q15[2 marks]
State the difference between opening a file in "w" mode and "a" mode.
Answer

"w" erases the entire contents of an existing file the moment it is opened, then writes from the beginning. "a" preserves the contents and adds new data at the end. Both create the file if it does not exist.

Q16[4 marks]
Write a C fragment that opens "data.txt" for reading, checks it opened, reads and prints integers until the end, and closes it.
Mark scheme
  1. FILE *fp; int n; fp = fopen("data.txt", "r");[1]
  2. if (fp == NULL) { printf("Cannot open file\n"); return 1; }the NULL check is a mark[1]
  3. while (fscanf(fp, "%d", &n) == 1) { printf("%d\n", n); }testing the return value, not feof[1]
  4. fclose(fp);[1]

Open, check NULL, loop while fscanf returns 1, close.

Q17[4 marks]
A program should add a new record to an existing file but instead the file contains only the newest record. Explain the fault and its correction.
Mark scheme
  1. The file has been opened in "w" mode instead of "a"[1]
  2. "w" truncates the file to zero length as soon as it is opened, destroying every existing recordthe truncation happens on opening[1]
  3. The new record is then written into an empty file, which is why only it remains[1]
  4. Correct it by opening with "a", which preserves the contents and appends at the end[1]

The file was opened with "w", which truncates it. Use "a" to append.

Q18[6 marks]
A school stores student marks in a text file, one record per line as a name followed by a mark.
  1. Write the code to read the file and count how many students scored 50 or above.
  2. Explain why fclose must be called.
  3. Explain why while (!feof(fp)) is an unreliable loop condition.
Mark scheme
  1. Opens the file in "r" mode and checks the pointer is not NULL[1]
  2. while (fscanf(fp, "%s %d", name, &marks) == 2) {two items requested, two expected back[1]
  3. if (marks >= 50) count++; } then prints the count after the loopcount initialised before the loop[1]
  4. fclose flushes the output buffer, so data still held in memory is actually written to disk[1]
  5. It also releases the file handle, a limited operating-system resource that would otherwise run out[1]
  6. feof becomes true only after a read has already failed, so the loop body runs one extra time and the previous values are processed twicetesting the read's return value avoids this[1]

(a) open, check, loop on fscanf == 2 counting passes (b) flushes the buffer and releases the handle (c) feof is set after a failed read, so the last record is processed twice

11

Programming

Multiple choice · 24

Q1What does input() return?

  1. Aan integer
  2. Ba string
  3. Ca float
  4. Dwhatever type was typed
Show answer

Correct answer: B — a string

Always a string. Python cannot know what you intended, so it hands back the characters and leaves the conversion to you.

Q2If the user types 4 and 6 into a = input(); b = input(); print(a + b), the output is:

  1. A10
  2. B46
  3. Can error
  4. D4 6
Show answer

Correct answer: B — 46

Both are strings, so + joins them into "46". No error is raised, which is why this bug is so easy to miss.

Q39 // 4 evaluates to:

  1. A2.25
  2. B2
  3. C1
  4. D2.0
Show answer

Correct answer: B — 2

Integer division discards the fractional part and returns a whole number. 9 / 4 would give 2.25.

Q410 % 3 evaluates to:

  1. A3
  2. B1
  3. C3.33
  4. D0
Show answer

Correct answer: B — 1

10 divided by 3 is 3 remainder 1, and % returns the remainder. This is how you test divisibility: a remainder of 0 means it divides exactly.

Q5Which is a valid Python variable name?

  1. A2marks
  2. Btotal marks
  3. Ctotal_marks
  4. Dprint
Show answer

Correct answer: C — total_marks

Names cannot start with a digit or contain spaces, and print is a built-in that should not be reused. Underscores are the usual way to join words.

Q6x = 5 followed by x = 8 results in:

  1. Atwo variables
  2. Bx holding 8
  3. Can error
  4. Dx holding 13
Show answer

Correct answer: B — x holding 8

The second assignment points the same name at a new value. The 5 is simply discarded.

Q7To compare whether two values are equal you use:

  1. A=
  2. B==
  3. C=>
  4. D!=
Show answer

Correct answer: B — ==

A single = assigns. A double == compares and produces True or False; != tests for inequality.

Q8Swapping the values of a and b requires:

  1. Aa = b then b = a
  2. Ba third temporary variable
  3. Cnothing — Python swaps automatically
  4. Da loop
Show answer

Correct answer: B — a third temporary variable

After a = b the original value of a is gone, so b = a just copies b back to itself. Saving the old value in temp first is what makes the swap work.

Q9How many times does for i in range(3, 8): repeat?

  1. A3
  2. B5
  3. C8
  4. D6
Show answer

Correct answer: B — 5

i takes the values 3, 4, 5, 6, 7 — five values. The upper bound 8 is where it stops and is never used.

Q10Which loop suits "keep asking until the password is correct"?

  1. Afor
  2. Bwhile
  3. Cif
  4. Drange
Show answer

Correct answer: B — while

The number of attempts is unknown in advance and depends on what the user types, which is exactly the condition-controlled case.

Q11In Python, what determines which lines are inside an if block?

  1. Acurly brackets
  2. Bsemicolons
  3. Cindentation
  4. Dthe end keyword
Show answer

Correct answer: C — indentation

Indentation is grammatical in Python. Moving a line by four spaces changes which block it belongs to and therefore what the program does.

Q12With m = 90, the chain if m>=40 … elif m>=80 … prints the grade for 40 because:

  1. A90 is not 80
  2. BPython stops at the first true condition
  3. Celif is not allowed
  4. Dthe indentation is wrong
Show answer

Correct answer: B — Python stops at the first true condition

The first test succeeds, so the chain ends there and the later branches are never examined. Conditions must run from most restrictive to least.

Q13A while loop that never ends usually means:

  1. Athe condition is too complex
  2. Bnothing inside changes the condition variable
  3. Cthe loop is nested
  4. Drange was used
Show answer

Correct answer: B — nothing inside changes the condition variable

If the variable the condition tests is never modified, the condition stays true for ever. Every while loop needs something inside it that moves towards stopping.

Q14Two nested loops each running 5 times execute the inner body:

  1. A5 times
  2. B10 times
  3. C25 times
  4. Dunknown
Show answer

Correct answer: C — 25 times

The inner loop runs completely for every pass of the outer one, so 5 × 5 = 25.

Q15Where should total = 0 be placed when summing values in a loop?

  1. Ainside the loop
  2. Bbefore the loop
  3. Cafter the loop
  4. Dit does not matter
Show answer

Correct answer: B — before the loop

Inside, it would reset to zero on every pass and the final total would be just the last value added.

Q16break in a loop:

  1. Askips one pass
  2. Bexits the loop immediately
  3. Crestarts the loop
  4. Dcauses an error
Show answer

Correct answer: B — exits the loop immediately

It leaves the loop entirely. continue is the one that skips only the current pass.

Q17In int square(int n) called as square(4), the argument is:

  1. An
  2. B4
  3. Cint
  4. Dsquare
Show answer

Correct answer: B — 4

4 is the actual value supplied at the call. n is the parameter that receives it.

Q18C passes arguments to functions:

  1. Aby reference
  2. Bby value
  3. Cby name
  4. Dby address always
Show answer

Correct answer: B — by value

The function receives a copy, which is why changing a parameter leaves the caller's variable untouched.

Q19void f(int x) { x = 99; } called with f(a) where a is 5 leaves a as:

  1. A99
  2. B5
  3. C0
  4. Dundefined
Show answer

Correct answer: B — 5

x is a copy. Assigning to it changes only that copy, which is discarded when the function returns.

Q20To let a function modify the caller's variable you pass:

  1. Athe value
  2. Bthe address
  3. Ca global
  4. Da copy
Show answer

Correct answer: B — the address

The address gives the function a route back to the original storage, which is exactly what the & in scanf provides.

Q21A function prototype is placed:

  1. Aafter main
  2. Bbefore main
  3. Cinside main
  4. Din a separate program
Show answer

Correct answer: B — before main

It must appear before any call, and C reads the file from the top, so above main is the conventional place.

Q22A variable declared inside a function is:

  1. Aglobal
  2. Blocal, existing only during the call
  3. Cpermanent
  4. Dshared with all functions
Show answer

Correct answer: B — local, existing only during the call

It is created when the function starts and destroyed when it returns, which is what keeps functions independent of each other.

Q23Global variables are discouraged because:

  1. Athey are slower
  2. Bany function can change them, making faults hard to trace
  3. Cthey use more memory
  4. DC does not allow them
Show answer

Correct answer: B — any function can change them, making faults hard to trace

When a global holds a wrong value, the culprit could be any function in the program. Parameters and return values keep the effects visible.

Q24A recursive function without a base case will:

  1. Areturn 0
  2. Brun until memory is exhausted
  3. Crefuse to compile
  4. Dcall itself once
Show answer

Correct answer: B — run until memory is exhausted

Each call makes another, and every one consumes stack space. Eventually the stack overflows and the program crashes.

Exam-style questions · 18

Q1[2 marks]
What is a variable, and what does x = 10 do?
Answer

A variable is a named location in memory holding a value. x = 10 creates the name x and assigns the integer value 10 to it. Assigning again later replaces the value rather than creating a second variable.

Q2[2 marks]
Why must int() often be used with input()?
Answer

Because input() always returns a string, even when the user types digits. Without conversion, + would join the text instead of adding — "5" + "3" gives "53" — and comparisons would compare text rather than numeric value.

Q3[2 marks]
State the difference between = and ==.
Answer

= is the assignment operator, storing a value in a variable. == is the comparison operator, testing whether two values are equal and producing True or False.

Q4[4 marks]
Write a Python program that asks the user for the length and width of a rectangle and prints its area.
Mark scheme
  1. length = float(input("Enter length: "))float rather than int allows decimal measurements[1]
  2. width = float(input("Enter width: "))[1]
  3. area = length * widtha meaningful variable name is expected[1]
  4. print("The area is", area)output must be labelled, not a bare number[1]

Read both values as floats, multiply, and print with a label.

Q5[4 marks]
State the output of each: (i) print(7 // 2) (ii) print(7 % 2) (iii) print(7 / 2) (iv) print(2 ** 3)
Mark scheme
  1. (i) 3 — integer division discards the remaindernot 3.5[1]
  2. (ii) 1 — the remainder when 7 is divided by 2[1]
  3. (iii) 3.5 — / always produces a floatnote the decimal point[1]
  4. (iv) 8 — ** is the power operator2 cubed[1]

(i) 3 (ii) 1 (iii) 3.5 (iv) 8

Q6[6 marks]
A student writes this program to calculate a average of two test marks: a = input("Mark 1: "), b = input("Mark 2: "), avg = a + b / 2, print(avg)
  1. Identify two errors in this program.
  2. Write a corrected version.
  3. Explain how you would test that your corrected version works.
Mark scheme
  1. Error 1: the inputs are strings, so they are joined rather than addedint() or float() is missing[1]
  2. Error 2: operator precedence — a + b / 2 divides b by 2 first, so brackets are needed: (a + b) / 2this error survives even after the type is fixed[1]
  3. Corrected input lines using float(input(…))[1]
  4. avg = (a + b) / 2 followed by a labelled print[1]
  5. Test with normal data, such as 60 and 80, and check the answer is 70a value you can verify by hand[1]
  6. Test with boundary data such as 0 and 100, and with erroneous data such as text, to see how it behavesall three kinds of test data[1]

(a) inputs not converted, and missing brackets (b) float(input(…)) and (a+b)/2 (c) normal, boundary and erroneous data

Q7[2 marks]
Name the three control structures and give one Python keyword for each.
Answer

Sequence — statements written one after another, needing no keyword. Selectionif. Iterationfor or while.

Q8[2 marks]
When should a while loop be used instead of a for loop?
Answer

When the number of repetitions is not known in advance and depends on a condition evaluated during the loop — for example repeating until the user enters valid input or types "quit". A for loop is used when the count is fixed beforehand.

Q9[2 marks]
How many times does the body of for i in range(2, 7): execute?
Answer

Five times, with i taking the values 2, 3, 4, 5 and 6. The upper bound 7 is where the sequence stops and is not itself used.

Q10[4 marks]
Write a Python program that prints the numbers from 1 to 20 that are divisible by 3.
Mark scheme
  1. for n in range(1, 21): — the upper bound must be 21 to include 20the off-by-one is examined here[1]
  2. if n % 3 == 0:the remainder test for divisibility[1]
  3. print(n) correctly indented inside the ifindentation is part of the mark[1]
  4. Output: 3, 6, 9, 12, 15, 18[1]

A for loop over range(1, 21) with an if n % 3 == 0 test inside.

Q11[4 marks]
This code is intended to count down from 5 to 1 but instead runs for ever. Identify the fault and correct it. count = 5 / while count > 0: / print(count)
Mark scheme
  1. Nothing inside the loop changes count[1]
  2. So the condition count > 0 is true on every pass and never becomes false — an infinite loopnaming it as infinite is expected[1]
  3. Add count = count - 1 inside the loopaccept count -= 1[1]
  4. It must be indented inside the loop; placed outside it would run only once, after the loopthe indentation point is a mark[1]

The loop variable is never decremented. Add count = count - 1 indented inside the loop.

Q12[6 marks]
A program should read ten test marks, count how many are 50 or above, and print both the count and the average.
  1. State which loop type is appropriate and why.
  2. Write the program.
  3. Explain where the print statements must be placed and why.
Mark scheme
  1. A for loop, because the number of marks is known in advance to be tenthe reason must be given[1]
  2. Initialise total = 0 and passes = 0 before the loopaccumulators must start outside the loop[1]
  3. for i in range(10): then read a mark and add it to total[1]
  4. if mark >= 50: passes = passes + 1, correctly indented inside the loop[1]
  5. After the loop: print(passes) and print(total / 10)[1]
  6. The prints must be outside the loop, because inside they would run on every pass and print ten partial results instead of one final answerthe reason is the mark[1]

(a) for, since ten is known (b) accumulators before, loop reads and tests, prints after (c) outside, or they print ten partial results

Q13[2 marks]
State two advantages of using functions.
Answer

Reusability — code written once can be called many times, so a correction is made in one place. Testability and readability — each function can be understood and tested on its own, and a long program becomes a set of short comprehensible pieces.

Q14[2 marks]
Differentiate between a parameter and an argument.
Answer

A parameter is the variable named in the function definition, which receives a value. An argument is the actual value supplied at the point of call. In square(6) calling int square(int n), n is the parameter and 6 is the argument.

Q15[2 marks]
Why is a function prototype needed?
Answer

C processes a file from top to bottom, so a function called before its definition appears has not yet been seen by the compiler. A prototype placed above main declares the name, return type and parameter types in advance, allowing the call to be checked.

Q16[4 marks]
Write a C function that takes two integers and returns the larger, and show how it is called.
Mark scheme
  1. int larger(int a, int b) { — correct return type and two int parameters[1]
  2. if (a > b) return a;[1]
  3. else return b; }every path must return a value[1]
  4. Called as int max = larger(7, 3); with the returned value stored or usedcalling it without using the result wastes it[1]

int larger(int a, int b) with an if-else returning a or b, called as larger(7, 3).

Q17[4 marks]
Explain why a C function cannot normally change a variable belonging to the caller, and how it can be made to.
Mark scheme
  1. C passes arguments by value — the function receives a copy of the argument[1]
  2. The parameter is a separate variable, so assigning to it changes only the copy, which is discarded when the function ends[1]
  3. To change the original, pass its address using &, and declare the parameter as a pointer[1]
  4. The function then writes through that address with *, reaching the caller's variable — which is exactly what scanf doesthe scanf connection earns the mark[1]

Pass by value means the function gets a copy. Pass the address instead and write through the pointer.

Q18[6 marks]
A program calculates the area of several circles.
  1. Write a function that takes a radius and returns the area, using a constant for π.
  2. Explain the difference between a local and a global variable, and which the function should use.
  3. Explain what would happen if the function were called before being declared or defined.
Mark scheme
  1. #define PI 3.14159 or const float PI = 3.14159;[1]
  2. float area(float r) { return PI * r * r; }float return type and parameter[1]
  3. A local variable is declared inside a function and exists only while it runs; a global is declared outside all functions and is visible everywhere[1]
  4. The radius should be a parameter and any working values local, so the function depends only on what it is given and cannot be affected by the rest of the program[1]
  5. C reads the file top to bottom, so calling it earlier with no prototype means the compiler has not seen the declaration[1]
  6. The compiler reports an error, or in older C assumes a default return type of int and produces a wrong result silentlythe silent-failure case is the sharper point[1]

(a) float area(float r) returning PI * r * r (b) local for working values; parameters for input (c) an error, or in older C a silent wrong result from an assumed int return

12

Software Development

Multiple choice · 8

Q1Which stage is most often skipped and most expensive to skip?

  1. AImplementation
  2. BRequirements gathering
  3. CDeployment
  4. DDocumentation
Show answer

Correct answer: B — Requirements gathering

Skipping it means building the wrong thing correctly, and the error surfaces only at the end when change costs most.

Q2"The report must be produced within five seconds" is:

  1. Aa functional requirement
  2. Ba non-functional requirement
  3. Ca test case
  4. Da design decision
Show answer

Correct answer: B — a non-functional requirement

It describes how well the system performs, not what it does. It is also testable, which is what makes it a good non-functional requirement.

Q3The waterfall model is best suited to projects where:

  1. Arequirements change often
  2. Brequirements are stable and well understood
  3. Cthe customer is unavailable
  4. Dno documentation is needed
Show answer

Correct answer: B — requirements are stable and well understood

Its sequential structure only works if the early decisions hold. Changing requirements are exactly what it handles badly.

Q4Integration testing checks:

  1. Aone function in isolation
  2. Bthat separate units work together
  3. Cthe customer's satisfaction
  4. Dthe hardware
Show answer

Correct answer: B — that separate units work together

Units that pass individually frequently fail when combined, because each made assumptions about the others. That is where most faults appear.

Q5For a field accepting 1 to 100, boundary test data would be:

  1. A50 and 60
  2. B1, 100, 0 and 101
  3. Conly 1
  4. Dletters
Show answer

Correct answer: B — 1, 100, 0 and 101

Boundary testing uses the limits and the values immediately outside them, which is where off-by-one errors live. Option A is normal data and letters are erroneous data.

Q6Acceptance testing is carried out by:

  1. Athe developer
  2. Bthe customer
  3. Cthe compiler
  4. Dan automated tool
Show answer

Correct answer: B — the customer

It decides whether the system meets what the customer meant, and a developer testing their own interpretation cannot detect a misinterpretation.

Q7Passing all tests means the software is:

  1. Aproved correct
  2. Bfree of known faults, but not proved correct
  3. Cready to abandon
  4. Dfully documented
Show answer

Correct answer: B — free of known faults, but not proved correct

Testing can show the presence of faults but never their absence. A program may pass every test written and still fail on the case nobody thought of.

Q8Maintenance in the life cycle refers to:

  1. Acleaning the hardware
  2. Bfixing, adapting and improving the system after deployment
  3. Cwriting the first version
  4. Dgathering requirements
Show answer

Correct answer: B — fixing, adapting and improving the system after deployment

It typically consumes more of a system's total cost than the original development, because software must keep changing as the world it serves changes.

Exam-style questions · 6

Q1[2 marks]
Name the stages of the software development life cycle.
Answer

Requirements gathering, analysis, design, implementation, testing, deployment and maintenance. Different models order or repeat them differently, but these are the stages every project passes through.

Q2[2 marks]
Differentiate between functional and non-functional requirements, with an example of each.
Answer

A functional requirement states what the system must do — "the system shall calculate each student's attendance percentage". A non-functional requirement states how well it must do it — "each report shall be produced within five seconds".

Q3[2 marks]
Why is a fault found after deployment more expensive than one found during design?
Answer

By deployment the fault is embedded in written code that other parts depend on, users have been trained on the incorrect behaviour, and any damage it caused must also be repaired. During design it costs only a change to a document before anything was built on it.

Q4[4 marks]
Compare the waterfall and iterative models, giving one situation in which each is preferable.
Mark scheme
  1. Waterfall completes each stage fully and signs it off before the next begins; iterative repeats the stages in short cycles[1]
  2. In waterfall the customer sees working software only at the end; in an iterative model they see something usable every cycle[1]
  3. Waterfall suits a project whose requirements are fully known and stable — replacing a well-understood manual process, or a system whose rules are set by law[1]
  4. Iterative suits a project whose requirements are uncertain or likely to change, since misunderstandings surface within weeks rather than at the end[1]

Sequential and documented against cyclic and adaptable; waterfall for stable requirements, iterative for uncertain ones.

Q5[4 marks]
A login field accepts a password of 8 to 16 characters. State four items of test data, naming the type of each.
Mark scheme
  1. Normal: a 12-character password — acceptedcomfortably inside the range[1]
  2. Boundary: 8 characters and 16 characters — both acceptedthe limits are inside the allowed range[1]
  3. Boundary: 7 characters and 17 characters — both rejectedcatches > written instead of >=[1]
  4. Erroneous: an empty field — rejected with a clear message rather than a crashthe empty case is the one most often missed[1]

Normal 12; boundary 8, 16, 7, 17; erroneous empty.

Q6[6 marks]
A school asks a developer to build a system to record and report student attendance.
  1. Describe two techniques for gathering the requirements, and what each would reveal.
  2. Give one functional and one non-functional requirement for this system.
  3. Explain why acceptance testing must be carried out by the school rather than the developer.
Mark scheme
  1. Interviews with teachers and office staff, revealing what information they need and what the current process cannot do[1]
  2. Observation of the register being taken, revealing the exceptions and workarounds people no longer notice they use — late arrivals, half days, tripsobservation catches what interviews miss[1]
  3. Functional: "the system shall calculate each student's attendance percentage for a chosen date range"a specific, testable action[1]
  4. Non-functional: "a monthly report for a class of 40 shall be produced within five seconds"measurable, so it can be tested[1]
  5. Acceptance testing decides whether the system does what the customer actually asked for, so only the customer can judge it[1]
  6. The developer tests against their own understanding of the requirements — which is precisely what may have been wrong from the startthe circularity is the point[1]

(a) interviews for needs, observation for the unspoken exceptions (b) attendance percentage; report within five seconds (c) only the customer can say whether it does what they meant

13

Data Representation (A Level)

Multiple choice · 8

Q1In floating-point representation, the exponent determines the:

  1. Aprecision
  2. Brange
  3. Csign
  4. Dword length
Show answer

Correct answer: B — range

The exponent says how far the binary point shifts, setting how large or small a value can be. Precision comes from the mantissa.

Q2For a fixed word length, giving more bits to the mantissa:

  1. Aincreases both range and precision
  2. Bincreases precision and decreases range
  3. Cincreases range and decreases precision
  4. Dhas no effect
Show answer

Correct answer: B — increases precision and decreases range

The bits have to come from the exponent, so precision improves while range shrinks. The trade-off cannot be avoided.

Q3Which mantissa is correctly normalised for a positive number?

  1. A0.0110
  2. B0.1011
  3. C1.0110
  4. D1.1011
Show answer

Correct answer: B — 0.1011

A positive normalised mantissa begins 0.1. The third option is a normalised negative; the others are unnormalised.

Q4A negative normalised mantissa begins:

  1. A0.1
  2. B1.0
  3. C1.1
  4. D0.0
Show answer

Correct answer: B — 1.0

The sign bit is 1 and the next bit must differ from it, so it is 0.

Q5Shifting a mantissa left by two places requires the exponent to:

  1. Aincrease by 2
  2. Bdecrease by 2
  3. Cstay the same
  4. Ddouble
Show answer

Correct answer: B — decrease by 2

Each left shift multiplies the mantissa by 2, so the exponent must fall by one per shift to preserve the value.

Q60.1 cannot be stored exactly in binary because:

  1. Ait is too small
  2. Bits denominator is not a power of two
  3. Cit is negative
  4. Dthe exponent is too short
Show answer

Correct answer: B — its denominator is not a power of two

Binary fractions terminate only for denominators that are powers of two. One tenth recurs forever.

Q7Two floating-point values should be compared by:

  1. Ausing =
  2. Bchecking the difference is below a tolerance
  3. Cconverting to text
  4. Drounding to integers
Show answer

Correct answer: B — checking the difference is below a tolerance

Stored values are approximations, so numbers that should match may differ in their final bits. A tolerance test handles that.

Q8A value too close to zero to be represented causes:

  1. Aoverflow
  2. Bunderflow
  3. Crounding
  4. Dnormalisation
Show answer

Correct answer: B — underflow

Underflow is the small-magnitude case; overflow is when a value is too large for the exponent.

Exam-style questions · 5

Q1[2 marks]
State the effect on range and precision of increasing the number of bits allocated to the mantissa, keeping the total word length the same.
Answer

Precision increases, because more significant bits are stored. Range decreases, because fewer bits remain for the exponent, so the binary point cannot be shifted as far.

Q2[2 marks]
State how you can tell whether a two's complement floating-point number is normalised.
Answer

The first two bits of the mantissa must differ. A positive normalised number begins 0.1; a negative one begins 1.0.

Q3[4 marks]
A floating-point number has mantissa 0.0001101 and exponent 0101. Normalise it, showing each step.
Mark scheme
  1. The first two bits are 0.0, so the number is not normalised.Stating the test explicitly.[1]
  2. Shift left 1: 0.001101, exponent 0100. Shift left 2: 0.011010, exponent 0011.Each left shift reduces the exponent by one.[1]
  3. Shift left 3: 0.110100, exponent 0010.Three shifts were needed to bring a 1 next to the point.[1]
  4. Mantissa 0.110100, exponent 0010 — now normalised, since it begins 0.1.The exponent has fallen by 3 from 0101 to 0010.[1]

Mantissa 0.110100, exponent 0010

Q4[6 marks]
(a) Explain why the decimal value 0.1 cannot be stored exactly in binary floating point.
(b) State one consequence for a program that adds 0.1 to a running total ten thousand times.
(c) State how a programmer should test two floating-point values for equality, and why.
(d) Define overflow and underflow in this context.
Mark scheme
  1. (a) In binary a fraction terminates only if its denominator is a power of two. 0.1 is one tenth, so it recurs as 0.000110011… forever.The power-of-two condition is the reason.[1]
  2. The mantissa has a fixed number of bits, so the sequence is truncated and the stored value is slightly inaccurate.The truncation is what creates the error.[1]
  3. (b) The small error is repeated and accumulates, so the total drifts measurably from 1000.Accumulation is the point, not the single error.[1]
  4. (c) Test whether the absolute difference is less than a small tolerance, rather than using exact equality.The method must be stated concretely.[1]
  5. Because the stored values are approximations, two numbers that should be equal may differ in their last bits.The reason earns the second mark.[1]
  6. (d) Overflow: the value is too large for the exponent to represent. Underflow: the value is too small (too close to zero) to represent.Both are needed for the mark.[1]

(a) recurring binary, truncated; (b) accumulating drift; (c) compare against a tolerance; (d) too large / too small

Q5[2 marks]
Explain why normalisation is performed on floating-point numbers.
Answer

It removes leading zeros (or leading ones for negatives) from the mantissa, so no bits are wasted and the maximum precision is retained for a given word length. It also gives each value a unique representation, which makes comparison and arithmetic straightforward.

14

Communication and internet technologies

Multiple choice · 14

Q1Data is split into packets before transmission mainly because:

  1. APackets travel faster than whole files
  2. BLost data can be resent in small pieces and links can be shared
  3. CComputers cannot store whole files
  4. DIt encrypts the data
Show answer

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?

  1. ATCP, because reliability matters most
  2. BUDP, because late data is useless anyway
  3. CHTTP, because it is a web application
  4. DSMTP, because it streams
Show answer

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:

  1. AAssigned by your router each time you connect
  2. BFixed to the hardware and used only on the local network
  3. CAlways a public internet address
  4. DUsed to encrypt traffic
Show answer

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:

  1. AEncrypt web traffic
  2. BTranslate domain names into IP addresses
  3. CSplit data into packets
  4. DChoose the fastest route
Show answer

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:

  1. AData travels faster
  2. BEach layer can be changed without disturbing the others
  3. CFewer packets are needed
  4. DIt removes the need for addresses
Show answer

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:

  1. AA single SYN message
  2. BA three-way handshake: SYN, SYN-ACK, ACK
  3. CA DNS lookup
  4. DAn encrypted certificate exchange
Show answer

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.

Q7Which part of a packet contains the receiver's address?

  1. Apayload
  2. Bheader
  3. Ctrailer
  4. Dchecksum
Show answer

Correct answer: B — header

The header carries the addressing and sequencing information. The payload is the data itself and the trailer holds the error check.

Q8Serial transmission sends:

  1. Aseveral bits at once
  2. Bone bit at a time
  3. Cwhole bytes in parallel
  4. Donly text
Show answer

Correct answer: B — one bit at a time

One bit at a time down a single wire, which is why it works reliably over long distances.

Q9Skew is a problem for:

  1. Aserial transmission
  2. Bparallel transmission over distance
  3. Cwireless only
  4. Dpacket switching
Show answer

Correct answer: B — parallel transmission over distance

Bits travelling down separate wires arrive at slightly different times, and over distance the gap becomes large enough to corrupt the data.

Q10A walkie-talkie is an example of:

  1. Asimplex
  2. Bhalf duplex
  3. Cfull duplex
  4. Dparallel
Show answer

Correct answer: B — half duplex

Both parties can transmit, but only one at a time — which is why users say "over" to hand the channel across.

Q11A telephone call is an example of:

  1. Asimplex
  2. Bhalf duplex
  3. Cfull duplex
  4. Dbroadcast
Show answer

Correct answer: C — full duplex

Both people can speak and be heard simultaneously, so data flows in both directions at the same time.

Q12If one packet arrives corrupted:

  1. Athe whole file is resent
  2. Bthat packet alone is requested again
  3. Cthe file is discarded
  4. Dnothing happens
Show answer

Correct answer: B — that packet alone is requested again

Packets are independent, so only the faulty one needs resending. This is one of the main reasons for packet switching.

Q13USB connectors cannot be inserted the wrong way round because:

  1. Athey are round
  2. Bthey are shaped to fit only one orientation
  3. Cthe software prevents it
  4. Dthey are magnetic
Show answer

Correct answer: B — they are shaped to fit only one orientation

The physical shape enforces it, which removes a whole class of user error before any software is involved.

Q14Parallel transmission is still used:

  1. Afor the internet
  2. Binside a computer over short distances
  3. Cfor USB
  4. Dfor Ethernet
Show answer

Correct answer: B — inside a computer over short distances

Over a few centimetres skew is negligible and the extra wires give real speed. Over metres it becomes unusable, so every external link is serial.

Exam-style questions · 12

Q1[2 marks]
State the difference between a LAN and a WAN.
Answer

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.

Q2[2 marks]
Explain the purpose of an IP address and a MAC address.
Answer

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.

Q3[3 marks]
Describe what happens when data is split into packets for transmission.
Answer

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.

Q4[8 marks]
A school is setting up a network for 30 computers in one building.
  1. State whether a LAN or a WAN is appropriate and justify your choice. [2]
  2. Describe the function of a router and of a switch in this network. [4]
  3. State two advantages of networking the computers rather than leaving them standalone. [2]
Mark scheme
  1. A LAN[1]
  2. The computers are all within a single building and the school owns the cabling[1]
  3. A switch connects devices within the LAN[1]
  4. It forwards each frame only to the port of the intended recipient, using MAC addresses[1]
  5. A router connects the LAN to another network, usually the internet[1]
  6. It forwards packets between networks using IP addresses[1]
  7. Advantage: files and printers can be shared[1]
  8. Advantage: software and backups can be managed centrally[1]
Q5[7 marks]
A student enters a web address into a browser and the page loads.
  1. Describe the role of the DNS in this process. [3]
  2. Explain the difference between HTTP and HTTPS. [2]
  3. State two reasons a school might use a firewall on this connection. [2]
Mark scheme
  1. The browser sends the domain name to a DNS server[1]
  2. The server looks up the matching IP address[1]
  3. The IP address is returned and the browser requests the page from that server[1]
  4. HTTPS encrypts the data in transit, HTTP sends it in plain text[1]
  5. So HTTPS protects information such as passwords from being read if intercepted[1]
  6. To block access to unsuitable or unauthorised sites[1]
  7. To inspect incoming traffic and block unauthorised access to the network[1]
Q6[5 marks]
A company is choosing between a wired and a wireless network for its office.
  1. Give one advantage of a wired connection. [1]
  2. Give one advantage of a wireless connection. [1]
  3. The company handles confidential data. Describe one security measure it should apply to a wireless network and explain how it helps. [3]
Mark scheme
  1. Faster and more reliable, with less interference[1]
  2. Devices can be moved freely and no cabling is needed[1]
  3. Use WPA encryption on the wireless network[1]
  4. Data sent over the air is scrambled[1]
  5. So anyone intercepting the signal cannot read it without the keyaccept MAC filtering or a strong passphrase, explained[1]
Q7[2 marks]
State two items contained in a packet header.
Answer

Any two of: the sender's address, the receiver's address, the packet number, and the total number of packets making up the file.

Q8[2 marks]
Explain why parallel transmission is unsuitable over long distances.
Answer

The bits travel at very slightly different speeds along different wires, so they arrive out of step — a problem called skew — and the data can no longer be read correctly. Long parallel cables also suffer crosstalk between adjacent wires.

Q9[2 marks]
Give an example of simplex transmission and explain why it is simplex.
Answer

A keyboard to a computer: data travels from the keyboard to the machine and never in the other direction, so only one direction is ever used.

Q10[4 marks]
Explain how a file is transmitted across the internet using packet switching, and give two advantages of doing so.
Mark scheme
  1. The file is divided into packets, each with a header containing the addresses and its packet number[1]
  2. Packets travel independently and may take different routes; the receiver reassembles them in order using the packet numbers[1]
  3. Advantage: a single corrupted or lost packet can be resent on its own rather than restarting the whole file[1]
  4. Advantage: many transfers share the same links, and a broken route can be avoided rather than stopping transmission[1]

Split into numbered packets, routed independently, reassembled by number — allowing resends and rerouting.

Q11[4 marks]
Classify each of the following by wires and by direction: (i) a USB connection to an external drive, (ii) a walkie-talkie, (iii) the connection between a CPU and RAM.
Mark scheme
  1. (i) Serial — USB sends one bit at a time[1]
  2. (i) Full duplex in modern versions — data is read and written in both directionsaccept half duplex for USB 1 and 2 with justification[1]
  3. (ii) Serial and half duplex — one party speaks at a time[1]
  4. (iii) Parallel, because the distance is very short, and full duplexinside the machine skew is not a problem[1]

(i) serial full duplex (ii) serial half duplex (iii) parallel

Q12[6 marks]
A company is connecting devices in a new office.
  1. Explain why the network cabling between rooms will use serial transmission.
  2. Give three advantages of USB for connecting peripherals.
  3. Explain what happens if one packet of a file arrives corrupted.
Mark scheme
  1. The distances between rooms are far too great for parallel transmission[1]
  2. Skew and crosstalk would corrupt the data, and serial also needs fewer wires so the cabling is cheaper[1]
  3. USB is a universal standard, so one type of connector serves many different devices[1]
  4. The connector cannot be inserted the wrong way round, and devices are detected automatically with drivers loaded — plug and play[1]
  5. It also supplies power as well as data, so small peripherals need no separate supplyany three advantages[1]
  6. The error-checking value in the trailer fails, so the receiver requests that packet again — only the one packet is resent, not the whole filethe point is that just one packet is affected[1]

(a) skew and crosstalk over distance (b) universal, one-way connector, plug and play, supplies power (c) that packet alone is requested again

15

Hardware and Virtual Machines

Multiple choice · 16

Q1In the von Neumann architecture, programs and data are:

  1. Astored in separate memories
  2. Bstored in the same memory
  3. Cnever stored
  4. Dstored only in registers
Show answer

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.

Q2The program counter holds:

  1. Athe current instruction
  2. Bthe address of the next instruction
  3. Cthe result of the last operation
  4. Dthe data just fetched
Show answer

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.

Q3During the fetch stage, the instruction is copied from the MDR into the:

  1. AACC
  2. BMAR
  3. CCIR
  4. DPC
Show answer

Correct answer: C — CIR

The current instruction register holds the instruction while the control unit decodes it.

Q4The address bus is unidirectional because:

  1. Ait is cheaper
  2. Bonly the processor generates addresses
  3. Cit carries no data
  4. Dmemory is read-only
Show answer

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.

Q5The von Neumann bottleneck arises because:

  1. Athe clock is too slow
  2. Binstructions and data share one bus
  3. Cthere is too much cache
  4. Dthere are too many cores
Show answer

Correct answer: B — instructions and data share one bus

Sharing a single bus means instruction fetches and data transfers cannot happen simultaneously.

Q6A single-threaded program on a quad-core processor runs:

  1. Afour times faster
  2. Bat about the same speed
  3. Cfour times slower
  4. Dtwice as fast
Show answer

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.

Q7A graphics processor applying the same operation to millions of pixels is an example of:

  1. ASISD
  2. BSIMD
  3. CMISD
  4. DMIMD
Show answer

Correct answer: B — SIMD

One instruction is applied to many data items simultaneously — Single Instruction, Multiple Data.

Q8A disadvantage of running software in a virtual machine is:

  1. Apoorer isolation
  2. Breduced performance from the extra layer
  3. Cit cannot be backed up
  4. Dit needs separate hardware
Show answer

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.

Q9In Boolean algebra, A + A equals:

  1. A2A
  2. BA
  3. C0
  4. D1
Show answer

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:

  1. AĀ · B̄
  2. BĀ + B̄
  3. CA + B
  4. DA · B
Show answer

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:

  1. Aare in numerical order
  2. Bdiffer in exactly one variable
  3. Chave the same value
  4. Dcan be ignored
Show answer

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:

  1. Aany number of cells
  2. Bonly powers of two
  3. Conly 3 cells
  4. Donly single cells
Show answer

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?

  1. A1
  2. B2
  3. C3
  4. D4
Show answer

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:

  1. Acannot be grouped
  2. Bform a valid group of 4
  3. Cform four separate groups
  4. Dmust be zeros
Show answer

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:

  1. AA
  2. BB
  3. CA + B
  4. DA · B
Show answer

Correct answer: C — A + B

Expanding gives (A + Ā)(A + B) = 1·(A + B) = A + B.

Q16NAND is functionally complete, which means:

  1. Ait is the fastest gate
  2. Bany circuit can be built from NAND gates alone
  3. Cit has two inputs
  4. Dit never fails
Show answer

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.

Exam-style questions · 10

Q1[2 marks]
State what is meant by the von Neumann architecture and identify one limitation of it.
Answer

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.

Q2[3 marks]
Describe the fetch stage of the fetch–decode–execute cycle, naming the registers used.
Answer

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.

Q3[2 marks]
Explain why the program counter is incremented during the fetch stage rather than after execution.
Answer

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.

Q4[6 marks]
(a) State the direction of data flow on the address bus and on the data bus, giving a reason for the address bus.
(b) Explain how increasing cache size can improve performance.
(c) A program runs at the same speed on a four-core processor as on a single core. Explain why.
(d) State one advantage and one disadvantage of using virtual machines.
Mark scheme
  1. (a) The address bus is unidirectional; the data bus is bidirectional.Both directions must be stated.[1]
  2. The address bus is one-way because only the processor generates addresses — memory never sends one back.The reason is the mark, not the direction alone.[1]
  3. (b) Cache is faster than main memory and holds recently or frequently used data, so more requests are met without a slow main-memory access.The speed difference must be mentioned.[1]
  4. This reduces the time the processor spends idle waiting for data.Linking to the bottleneck earns the second mark.[1]
  5. (c) The program is single-threaded, so the work is not divided between cores and only one core is used.The software, not the hardware, is the limitation.[1]
  6. (d) Advantage: several isolated systems on one machine, using hardware efficiently. Disadvantage: slower than running directly on hardware, because of the extra software layer.One of each is required.[1]

(a) address one-way, data two-way; (b) fewer slow memory accesses; (c) single-threaded; (d) isolation vs overhead

Q5[2 marks]
Distinguish between SIMD and MIMD, giving a typical use of each.
Answer

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.

Q6[2 marks]
State De Morgan's two laws.
Answer

(A · B)‾ = Ā + B̄ and (A + B)‾ = Ā · B̄. In words: break the bar and change the operation between the terms.

Q7[2 marks]
Explain why the headings on a Karnaugh map are arranged in the order 00, 01, 11, 10 rather than 00, 01, 10, 11.
Answer

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.

Q8[3 marks]
State three rules for forming groups on a Karnaugh map.
Answer

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.

Q9[6 marks]
(a) Simplify A·B + A·B̄ using Boolean algebra, showing each law used.
(b) Simplify A + Ā·B.
(c) Explain what is meant by saying NAND is functionally complete, and show how a NOT gate is made from one.
Mark scheme
  1. (a) A·B + A·B̄ = A·(B + B̄) — factorising, using the distributive law.Taking out the common factor is the first move.[1]
  2. B + B̄ = 1 by the inverse law, so A·1 = A by the identity law.Both laws should be named for full credit.[1]
  3. (b) A + Ā·B = (A + Ā)·(A + B) by distributionThis is the less obvious route; the absorption-style result can also be quoted.[1]
  4. = 1·(A + B) = A + BUsing the inverse and identity laws again.[1]
  5. (c) Functionally complete means any logic circuit can be built using only that one type of gate.The definition must mention building any circuit.[1]
  6. A NOT gate is made by connecting both inputs of a NAND together: NAND(A, A) = (A·A)‾ = Ā.The working using the idempotent law makes it convincing.[1]

(a) A; (b) A + B; (c) any circuit from one gate type; NAND(A,A) = NOT A

Q10[2 marks]
Explain why simplifying a Boolean expression before building the circuit is worthwhile.
Answer

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.

16

System Software (A Level)

Multiple choice · 16

Q1The always-resident core of an operating system is called the:

  1. Ashell
  2. Bkernel
  3. Cdriver
  4. DBIOS
Show answer

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.

Q2Twenty programs appear to run at once on one core because the OS:

  1. Auses more cores
  2. Bswitches between them very quickly
  3. Ccompresses them
  4. Druns them on the GPU
Show answer

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.

Q3A slow machine with constant disk activity most likely indicates:

  1. Aa virus
  2. BRAM is full and the OS is paging
  3. Ca broken monitor
  4. Dtoo few cores
Show answer

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.

Q4Which operating system type guarantees a maximum response time?

  1. AMulti-user
  2. BReal-time
  3. CSingle-tasking
  4. DDistributed
Show answer

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.

Q5File permissions typically control:

  1. Afile size
  2. Bread, write and execute rights
  3. Cthe file format
  4. Ddisk speed
Show answer

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.

Q6Emptying the recycle bin means the data is:

  1. Asecurely erased
  2. Bstill on the disk until overwritten
  3. Cmoved to the cloud
  4. Dcompressed
Show answer

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.

Q7Virtual memory addressing allows the OS to:

  1. Aincrease physical RAM
  2. Bgive each program a private address space mapped onto real RAM
  3. Cspeed up the CPU
  4. Dremove the need for a disk
Show answer

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.

Q8Adding RAM helps a heavily paging machine more than a faster SSD because it:

  1. Aremoves the need to page at all
  2. Bmakes the disk faster
  3. Creduces CPU load
  4. Dincreases clock speed
Show answer

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.

Q9An interpreter differs from a compiler in that it:

  1. Aproduces an executable file
  2. Btranslates and runs one statement at a time
  3. Cis always faster
  4. Donly works with assembly
Show answer

Correct answer: B — translates and runs one statement at a time

It translates as it executes and produces no output file, which is why it must be present every time the program runs.

Q10Which stage removes comments and whitespace?

  1. Asyntax analysis
  2. Blexical analysis
  3. Ccode generation
  4. Doptimisation
Show answer

Correct answer: B — lexical analysis

Lexical analysis breaks the source into tokens, discarding anything the later stages do not need.

Q11A missing closing bracket would be reported during:

  1. Alexical analysis
  2. Bsyntax analysis
  3. Csemantic analysis
  4. Doptimisation
Show answer

Correct answer: B — syntax analysis

It breaks the grammar of the language, which is exactly what syntax analysis checks.

Q12Using a variable that was never declared is caught during:

  1. Alexical analysis
  2. Bsyntax analysis
  3. Csemantic analysis
  4. Dcode generation
Show answer

Correct answer: C — semantic analysis

The statement can be grammatically perfect while still being meaningless, which is what semantic analysis tests for.

Q13Which translator must be present every time the program runs?

  1. Acompiler
  2. Bassembler
  3. Cinterpreter
  4. Dnone of them
Show answer

Correct answer: C — interpreter

An interpreter translates during execution, so it is required each run. A compiled executable is independent of its compiler.

Q14The main advantage of bytecode is:

  1. Ait runs faster than machine code
  2. Bit is portable across platforms
  3. Cit needs no virtual machine
  4. Dit cannot contain errors
Show answer

Correct answer: B — it is portable across platforms

One compiled file runs anywhere a suitable virtual machine exists. It is slightly slower than native machine code, not faster.

Q15A compiler is usually preferred for released software because:

  1. Ait reports errors one at a time
  2. Bthe executable runs faster and hides the source
  3. Cit needs no translation
  4. Dit is easier to debug
Show answer

Correct answer: B — the executable runs faster and hides the source

Translation has already happened, so it runs faster, and only the executable is distributed rather than the source code.

Q16Optimisation during compilation aims to:

  1. Afind syntax errors
  2. Bproduce faster or smaller code
  3. Cbuild the symbol table
  4. Dconvert tokens to a parse tree
Show answer

Correct answer: B — produce faster or smaller code

It improves the generated code. Error finding and tokenising belong to earlier stages.

Exam-style questions · 11

Q1[2 marks]
What is the kernel of an operating system?
Answer

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.

Q2[2 marks]
Explain how a single-core processor appears to run several programs at once.
Answer

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.

Q3[2 marks]
Why should everyday work not be done from an administrator account?
Answer

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.

Q4[4 marks]
Describe four services provided by an operating system.
Mark scheme
  1. Process management — scheduling which program uses the CPU and for how long[1]
  2. Memory management — allocating RAM to each program and keeping them separate[1]
  3. File management — organising storage into files and folders and controlling access to them[1]
  4. Device management — communicating with hardware through drivers; also accept security and user accounts[1]

Process, memory, file and device management — plus security and the user interface.

Q5[4 marks]
A computer with 4 GB of RAM becomes extremely slow when many applications are open, and the disk activity light stays on. Explain the cause and suggest two solutions.
Mark scheme
  1. RAM has filled, so the OS is moving pages of memory out to disk — paging or swappingthe constant disk light is the clue[1]
  2. Disk access is thousands of times slower than RAM, so every switch between programs now waits on the diskthe speed gap is the explanation[1]
  3. Solution: close unused applications and reduce the number of programs starting automatically[1]
  4. Solution: install more RAM, which removes the need to page rather than merely making paging fasteran SSD helps but does not fix the cause[1]

RAM is full and the OS is paging to disk. Close programs, or add RAM.

Q6[6 marks]
A hospital uses computers for two very different jobs: office machines for administration, and a monitor attached to a patient that must raise an alarm within a guaranteed time.
  1. State the type of operating system suited to each, with a reason.
  2. Explain what "real-time" guarantees and why it matters here.
  3. Explain one way file permissions protect patient records on the office machines.
Mark scheme
  1. Office machines: a single-user multi-tasking operating system, since one person at a time runs several applications togetheraccept multi-user for shared machines[1]
  2. Patient monitor: a real-time operating system[1]
  3. Real-time guarantees that a response occurs within a fixed maximum time, not merely quickly on averagethe guarantee is the distinguishing feature[1]
  4. For a patient monitor an alarm raised late is as dangerous as no alarm, so a predictable worst case matters more than average speed[1]
  5. File permissions grant read, write and execute rights separately to the owner, a group and others[1]
  6. So clinical staff can be given read access to records while administrative staff cannot open them at all, and only authorised users may alter themthe example must fit the hospital[1]

(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

Q7[2 marks]
State two differences between a compiler and an interpreter.
Answer

A compiler translates the whole program before it runs and produces an executable file, whereas an interpreter translates and executes one statement at a time and produces no file. A compiler also reports all errors together at the end, while an interpreter halts at the first error it meets.

Q8[3 marks]
Describe what happens during lexical analysis and syntax analysis.
Answer

Lexical analysis breaks the source into tokens, removes comments and whitespace, and builds the symbol table. Syntax analysis checks that the sequence of tokens obeys the grammar of the language, building a parse tree and reporting errors such as a missing bracket.

Q9[2 marks]
A program contains the statement count = "seven" + 1, where count is declared as an integer. State which stage of compilation reports this and why.
Answer

Semantic analysis. The statement is grammatically well-formed, so it passes syntax analysis, but it is meaningless because a string cannot be added to an integer and assigned to an integer variable — a type mismatch.

Q10[6 marks]
(a) Explain why a developer might use an interpreter while writing a program but a compiler to release it.
(b) State what optimisation does and give one example.
(c) Explain what bytecode is and the advantage it gives.
Mark scheme
  1. (a) An interpreter reports the first error immediately and lets a change be tested without a full rebuild, which suits development.The fast feedback loop is the point.[1]
  2. A compiled executable runs faster and can be distributed without the source code, which suits release.Speed and source privacy are both valid.[1]
  3. (b) Optimisation improves the generated machine code so it runs faster or takes less space.Either faster or smaller is acceptable.[1]
  4. For example, removing code that can never execute, or keeping a frequently used value in a register instead of memory.A concrete example is required for the mark.[1]
  5. (c) Bytecode is an intermediate form produced by the compiler, executed by a virtual machine rather than directly by the processor.The intermediate nature must be stated.[1]
  6. It is portable: the same compiled file runs on any platform with a suitable virtual machine, without recompiling.Portability is the advantage being tested.[1]

(a) fast feedback vs speed and privacy; (b) faster or smaller code; (c) portable intermediate form

Q11[2 marks]
Explain why an assembler is simpler than a compiler.
Answer

In assembly language each mnemonic corresponds to exactly one machine instruction, so translation is largely a matter of substituting opcodes and resolving addresses. A compiler must translate high-level statements that may each become many machine instructions, and must also perform syntax, semantic and optimisation work.

17

Security (A Level)

Multiple choice · 8

Q1Encryption prevents intercepted data from being:

  1. Acopied
  2. Bunderstood
  3. Cdeleted
  4. Dtransmitted
Show answer

Correct answer: B — understood

The data can still be taken and destroyed. What it cannot be is read, because without the key the ciphertext is meaningless.

Q2In asymmetric encryption, the public key:

  1. Adecrypts messages
  2. Bencrypts messages
  3. Cmust be kept secret
  4. Dis the same as the private key
Show answer

Correct answer: B — encrypts messages

It encrypts only. Even the sender cannot read the message back, which is why publishing the key is safe.

Q3The main problem with symmetric encryption is:

  1. Ait is slow
  2. Bthe key must be shared safely
  3. Cit needs two keys
  4. Dit cannot be broken
Show answer

Correct answer: B — the key must be shared safely

Any channel secure enough to send the key on would have been secure enough for the message itself. Asymmetric encryption exists to solve this.

Q4A brute force attack works by:

  1. Aguessing the algorithm
  2. Btrying every possible key
  3. Cintercepting the message
  4. Dflipping bits
Show answer

Correct answer: B — trying every possible key

It needs no cleverness, only time — which is why key length, and therefore the number of keys to try, is the defence.

Q5Encryption algorithms are published because:

  1. Athey are not important
  2. Bpublic scrutiny finds weaknesses
  3. Cthe key is also public
  4. Dit is a legal requirement
Show answer

Correct answer: B — public scrutiny finds weaknesses

A secret algorithm has been examined by very few people, and an undiscovered flaw is far more dangerous than a public one that has been fixed.

Q6Real secure connections use:

  1. Asymmetric only
  2. Basymmetric only
  3. Casymmetric to exchange a key, then symmetric
  4. Dneither
Show answer

Correct answer: C — asymmetric to exchange a key, then symmetric

Asymmetric solves the key distribution problem, then symmetric handles the bulk data because it is far faster.

Q7Adding one bit to a key length:

  1. Aadds one possible key
  2. Bdoubles the number of possible keys
  3. Chalves the security
  4. Dhas no effect
Show answer

Correct answer: B — doubles the number of possible keys

Each bit has two states, so every extra bit doubles the search space a brute force attack must cover.

Q8Entering card details on an HTTPS page that is actually a fake site:

  1. Ais safe because of the encryption
  2. Bdelivers the details securely to the attacker
  3. Ccannot happen
  4. Dtriggers a browser warning
Show answer

Correct answer: B — delivers the details securely to the attacker

The encryption works perfectly and protects the journey. It says nothing about who is at the other end, which is why phishing defeats it.

Exam-style questions · 6

Q1[2 marks]
Explain what encryption does to data being transmitted.
Answer

It scrambles the data using a key so that it becomes meaningless to anyone who intercepts it. Only someone with the correct key can decrypt it back into readable form.

Q2[2 marks]
Does encryption prevent data being intercepted? Explain.
Answer

No. The data can still be intercepted, copied or deleted exactly as before. What encryption prevents is the interceptor understanding what they have taken, because without the key the ciphertext is unreadable.

Q3[2 marks]
Why is a longer encryption key more secure?
Answer

Each extra bit doubles the number of possible keys, so a brute force attack — trying every key in turn — takes far longer. A key short enough to be tried exhaustively offers no real protection.

Q4[4 marks]
Compare symmetric and asymmetric encryption, giving one advantage of each.
Mark scheme
  1. Symmetric uses the same key to encrypt and decrypt[1]
  2. Advantage: it is much faster, so it suits large volumes of data[1]
  3. Asymmetric uses a public key to encrypt and a matching private key to decrypt[1]
  4. Advantage: no secret key needs to be exchanged, which removes the problem of getting the key to the recipient safelythe key distribution problem is the point[1]

Symmetric: one key, fast. Asymmetric: a public/private pair, no shared secret needed.

Q5[4 marks]
Explain why encryption algorithms are made public rather than kept secret.
Mark scheme
  1. A public algorithm can be examined by cryptographers worldwide[1]
  2. so weaknesses are found and corrected, rather than remaining hidden until an attacker discovers one[1]
  3. Security rests entirely on the key, which remains secret — knowing the method does not read the message[1]
  4. A secret algorithm has been checked by very few people, and once leaked offers no protection at all — "security through obscurity" is not security[1]

Public scrutiny finds weaknesses; secrecy rests on the key alone, not on the method.

Q6[6 marks]
A customer buys goods from an online shop and enters card details.
  1. Explain how HTTPS protects the card details in transit.
  2. Explain why the site uses both asymmetric and symmetric encryption.
  3. Explain one thing encryption does NOT protect against here.
Mark scheme
  1. The data is encrypted in the browser before it is sent, so anything intercepted on the way is ciphertext[1]
  2. Only the shop's server holds the key needed to decrypt it, so an interceptor sees nothing usable[1]
  3. Asymmetric encryption is used first, to exchange a symmetric key safely without any prior shared secret[1]
  4. Then symmetric encryption is used for the actual data, because it is far faster for the volume involvedthe combination is the mark[1]
  5. Encryption does not protect the data once it has been decrypted at the destination[1]
  6. If the shop's database is later breached, or if the customer was tricked into sending details to a fake site in the first place, encryption offers no protection — it secured the journey, not the endpointsaccept phishing as the example[1]

(a) encrypted before sending, decryptable only by the server (b) asymmetric to exchange the key, symmetric for speed (c) it protects the journey, not the endpoints — a breached database or a fake site defeats it

18

Artificial Intelligence (AI)

Multiple choice · 16

Q1In machine learning, the computer produces:

  1. Athe data
  2. Bthe rules
  3. Cthe hardware
  4. Dthe labels
Show answer

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:

  1. Aunsupervised learning
  2. Bsupervised learning
  3. Creinforcement learning
  4. Dnot machine learning
Show answer

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:

  1. Asupervised
  2. Bunsupervised
  3. Creinforcement
  4. Doverfitting
Show answer

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:

  1. Aunderfitting
  2. Boverfitting
  3. Cwell trained
  4. Dunsupervised
Show answer

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:

  1. Abugs in the code
  2. Bpatterns present in the training data
  3. Cslow hardware
  4. Dtoo much test data
Show answer

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:

  1. Apart of the training data
  2. Bdata the model has never seen
  3. Clabelled by the model
  4. Das small as possible
Show answer

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:

  1. Aruns too slowly
  2. Bcannot explain how it reached a decision
  3. Cneeds no data
  4. Dhas no output
Show answer

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:

  1. Abeing given the correct answers
  2. Breceiving rewards and penalties for its actions
  3. Cgrouping unlabelled data
  4. Dcopying another model
Show answer

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:

  1. Amoral judgement
  2. Bfinding patterns in large amounts of data
  3. Cunfamiliar novel situations
  4. Dexplaining its reasoning
Show answer

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:

  1. Areplacement
  2. Btriage
  3. Creinforcement learning
  4. Doverfitting
Show answer

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:

  1. Afalse negative
  2. Bfalse positive
  3. Cbias
  4. Dblack box
Show answer

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:

  1. Athe code is different
  2. Bthe population it learned from differs from the one it is used on
  3. Cthe hardware differs
  4. Dthe language differs
Show answer

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:

  1. Ait would be slower
  2. Bthe applicant could not be told why they were refused
  3. Ccomputers are expensive
  4. Dit needs internet
Show answer

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:

  1. Aworkers are retrained
  2. Ba skill is lost because it is always automated
  3. Cthe AI becomes less accurate
  4. Djobs are created
Show answer

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?

  1. Ae-waste from sensors
  2. Bthe electricity used to train large models
  3. Cpaper use
  4. Dwater in data entry
Show answer

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:

  1. Acreativity
  2. Bconsistency
  3. Cempathy
  4. Dexplainability
Show answer

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.

Exam-style questions · 12

Q1[2 marks]
Differentiate between artificial intelligence and machine learning.
Answer

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.

Q2[2 marks]
What is supervised learning? Give an example.
Answer

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.

Q3[2 marks]
Why must a model be tested on data it has not been trained on?
Answer

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.

Q4[4 marks]
Describe the difference between supervised, unsupervised and reinforcement learning, giving one use of each.
Mark scheme
  1. Supervised: trained on labelled data — for example spam detection from emails already marked spam or not[1]
  2. Unsupervised: trained on unlabelled data and finds structure itself — for example grouping customers into segments[1]
  3. Reinforcement: learns by acting and receiving rewards or penalties — for example a program learning to play a game[1]
  4. The distinguishing factor is what the training data contains: answers, no answers, or a reward signalthe unifying statement earns the fourth mark[1]

Labelled data, unlabelled data, and reward feedback respectively.

Q5[4 marks]
A bank uses a machine learning model trained on its past lending decisions to approve loans. Explain how bias could arise and state two ways to reduce it.
Mark scheme
  1. The model learns the patterns in the historical decisions, including any that were unfair[1]
  2. If certain groups were refused disproportionately in the past, the model reproduces that pattern while appearing objectivethe appearance of objectivity is part of the harm[1]
  3. Reduce it by examining the training data for representativeness, and testing outcomes separately for each group[1]
  4. And by keeping a human decision-maker for consequential decisions, with a documented route to appealaccept requiring the model to be explainable[1]

The model learns historical unfairness. Audit the data, test outcomes per group, and keep human oversight.

Q6[6 marks]
A school wants to use machine learning to predict which students are at risk of failing, so extra help can be offered.
  1. Describe the data the system would need and how it would be trained.
  2. Explain one way the system could produce unfair results.
  3. Explain why a teacher should review every prediction before action is taken.
Mark scheme
  1. Historical records of past students — attendance, assessment marks, homework completion — each labelled with whether that student ultimately passed or failedlabelled data, so this is supervised learning[1]
  2. The data is split into a training set and a test set; the model learns from the first and is measured on the second[1]
  3. Unfairness: if the historical data reflects a group that was under-supported in the past, the model predicts failure for that group and the prediction becomes self-fulfilling[1]
  4. Or: a feature that correlates with background rather than ability — such as distance travelled to school — drives the predictioneither example accepted[1]
  5. A prediction is a statistical likelihood about a group, not a fact about the individual student in front of the teacher[1]
  6. The model cannot explain its reasoning, and being labelled "likely to fail" could itself affect how a student is treated and how they see themselves[1]

(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

Q7[2 marks]
Give one application of AI in healthcare and state its main benefit.
Answer

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.

Q8[2 marks]
State two disadvantages of using AI in decision-making.
Answer

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.

Q9[2 marks]
Explain one way AI can help farmers.
Answer

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.

Q10[4 marks]
Describe two benefits and two risks of self-driving vehicles.
Mark scheme
  1. Benefit: they do not tire, become distracted or drive under the influence, and human error causes most collisions[1]
  2. Benefit: they can give independent mobility to people unable to drive, and can coordinate to reduce congestion[1]
  3. Risk: an unfamiliar situation not represented in training may be handled badly, and roads present many such situations[1]
  4. Risk: responsibility for a collision is unclear — the owner, the manufacturer or the software developer — and the vehicle is a target for interferenceaccept job losses among professional drivers[1]

Benefits: no fatigue or distraction, and mobility for non-drivers. Risks: unfamiliar situations, and unclear liability.

Q11[4 marks]
A bank introduces an AI system to detect fraudulent transactions. Explain why this suits AI, and state one problem it may cause customers.
Mark scheme
  1. There are millions of transactions, far more than any human team could examine[1]
  2. Fraud shows as an unusual pattern, and finding patterns in large volumes of data at speed is exactly what these systems do well[1]
  3. Problem: false positives — a legitimate but unusual transaction is blocked, such as a card used abroad on holiday[1]
  4. The customer is inconvenienced and may not be told why, since the system cannot explain the pattern it reacted tothe inability to explain is the sharper point[1]

The volume and the pattern-matching suit AI; the cost is blocked legitimate transactions with no explanation.

Q12[6 marks]
A government department proposes using AI to decide which applicants receive financial assistance, replacing the current human assessors.
  1. Give two arguments in favour of the proposal.
  2. Give two arguments against.
  3. Recommend how the system should be used, with justification.
Mark scheme
  1. In favour: decisions would be made far faster and applicants would wait less[1]
  2. In favour: the same rules would be applied to every applicant, removing the inconsistency between individual assessors[1]
  3. Against: trained on past decisions, it would reproduce any historical unfairness while appearing objective[1]
  4. Against: an applicant refused assistance could not be told why, and would have no meaningful basis for appealthe accountability point[1]
  5. Recommendation: use the system to sort and prioritise applications, with a human assessor making every final decision[1]
  6. Justified because the speed and consistency are gained while accountability and the right to an explanation are preserved, and unusual cases still reach a personthe justification must address both sides[1]

(a) speed and consistency (b) inherited bias and no explanation (c) AI prioritises, humans decide — keeping the benefit and the accountability

19

Computational thinking and Problem-solving

Multiple choice · 14

Q1An algorithm takes 5n + 300 steps. What is its complexity?

  1. AO(5n + 300)
  2. BO(n)
  3. CO(300)
  4. DO(n²)
Show answer

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).

Q2Binary search on a sorted array of 1,000,000 items takes roughly how many comparisons?

  1. A1,000,000
  2. B1,000
  3. C20
  4. D2
Show answer

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.

Q3Which sort is fastest on data that is already almost sorted?

  1. ASelection sort
  2. BInsertion sort
  3. CBubble sort with no early exit
  4. DAll are identical
Show answer

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.

Q4Quicksort is O(n log n) on average. When does it degrade to O(n²)?

  1. AWhen the array contains duplicates
  2. BWhen the pivot repeatedly splits the array very unevenly
  3. CWhen n is a prime number
  4. DIt never degrades
Show answer

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.

Q5Why does O(2ⁿ) become unusable so quickly?

  1. AIt uses too much memory
  2. BEvery extra input element doubles the total work
  3. CIt only works on sorted data
  4. DIt requires recursion
Show answer

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.

Q6Two algorithms are O(n). One runs in 2 seconds, the other in 10. What does Big-O say about this?

  1. ABig-O is wrong here
  2. BNothing — Big-O describes growth rate, not absolute speed
  3. CThey must have different complexities
  4. DThe 10-second one is really O(n²)
Show answer

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.

Q7A recursive routine must always contain:

  1. Aa loop
  2. Ba base case
  3. Can array
  4. Da global variable
Show answer

Correct answer: B — a base case

The base case is what allows the recursion to stop. Without it the calls never end.

Q8A recursive function with no base case will:

  1. Areturn zero
  2. Bcause a stack overflow
  3. Crun faster
  4. Dskip the recursion
Show answer

Correct answer: B — cause a stack overflow

Every call pushes a frame and none ever returns, so the stack memory is exhausted.

Q9A stack frame stores:

  1. Aonly the return value
  2. Bthe return address, parameters and local variables
  3. Cthe whole program
  4. Dnothing
Show answer

Correct answer: B — the return address, parameters and local variables

It holds everything needed to resume the suspended call once the deeper one returns.

Q10For F(n) = n × F(n−1) with F(1) = 1, calling F(4) pushes how many frames?

  1. A1
  2. B3
  3. C4
  4. D24
Show answer

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.

Q11During recursion, calculations happen:

  1. Aon the way down
  2. Bon the way back up after the base case
  3. Call at once at the start
  4. Dnot at all
Show answer

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.

Q12Recursive calls complete in which order?

  1. Afirst in, first out
  2. Blast in, first out
  3. Crandom order
  4. Dall simultaneously
Show answer

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.

Q13The main disadvantage of recursion compared with iteration is:

  1. Ait cannot solve the same problems
  2. Bit uses more memory for stack frames
  3. Cit is harder to write
  4. Dit always gives wrong answers
Show answer

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.

Q14Recursion is most naturally suited to:

  1. Asumming a list of numbers
  2. Btraversing a tree
  3. Ccounting to ten
  4. Dreading one input
Show answer

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.

Exam-style questions · 11

Q1[2 marks]
State one condition that must be met before a binary search can be used, and state why.
Answer

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.

Q2[2 marks]
Explain what is meant by the time complexity of an algorithm.
Answer

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.

Q3[3 marks]
A linear search of 1000 items takes at most 1000 comparisons. State the maximum number a binary search would need, and explain.
Answer

About 10, because 2¹⁰ = 1024. Each comparison halves the remaining list, so the maximum is log₂ n rounded up.

Q4[7 marks]
A bubble sort is used on the list 5, 3, 8, 1.
  1. Write out the list after each complete pass. [3]
  2. State the total number of passes needed and explain how the algorithm knows it has finished. [2]
  3. State the time complexity of a bubble sort and explain why it is unsuitable for large data sets. [2]
Mark scheme
  1. After pass 1: 3, 5, 1, 8[1]
  2. After pass 2: 3, 1, 5, 8[1]
  3. After pass 3: 1, 3, 5, 8[1]
  4. Three passes; a fourth confirms no swaps[1]
  5. A flag records whether any swap was made; if a whole pass makes none, the list is sorted[1]
  6. O(n²)[1]
  7. Doubling the data quadruples the work, so it becomes impractically slow[1]
Q5[8 marks]
A program must find whether a student name appears in a sorted list of 5000 names.
  1. Write pseudocode for a binary search on this list. [5]
  2. Explain what your code returns when the name is not present. [1]
  3. Compare the number of comparisons with a linear search on the same list. [2]
Mark scheme
  1. Initialises low = 1 and high = 5000[1]
  2. Loops while low <= high[1]
  3. Calculates mid = (low + high) DIV 2[1]
  4. Compares and returns mid if the name matches[1]
  5. Otherwise sets high = mid − 1 or low = mid + 1 correctly[1]
  6. Returns a value such as −1 or FALSE once low > high[1]
  7. Binary search: at most 13 comparisons, since 2¹³ = 8192[1]
  8. Linear search: up to 5000, so binary search is dramatically faster[1]
Q6[5 marks]
An algorithm is described as having complexity O(n log n).
  1. Name one sorting algorithm with this complexity. [1]
  2. Explain why it scales better than O(n²) as n grows. [2]
  3. A data set of 1000 items takes 2 seconds with the O(n log n) algorithm. Estimate the time for 2000 items and justify your estimate. [2]
Mark scheme
  1. Merge sort or quicksort (average case)[1]
  2. The log n factor grows very slowly compared with the extra factor of n[1]
  3. So the gap between the two widens rapidly as n increases[1]
  4. Doubling n slightly more than doubles n log n[1]
  5. So roughly 4.2 to 4.5 seconds, a little over doubleaccept "just over 4 seconds" with reasoning[1]
Q7[2 marks]
State the two conditions a recursive routine must satisfy in order to terminate.
Answer

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.

Q8[3 marks]
Explain the role of the stack when a recursive routine executes.
Answer

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.

Q9[2 marks]
A recursive function is written with no base case. Describe what happens when it runs.
Answer

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.

Q10[6 marks]
A function is defined as: S(1) = 1, and S(n) = n + S(n−1) for n > 1.
(a) State the base case and the recursive case.
(b) Trace S(5), showing the calls and the returns.
(c) Give one advantage and one disadvantage of using recursion here rather than a loop.
Mark scheme
  1. (a) Base case: S(1) = 1. Recursive case: S(n) = n + S(n−1).Both must be identified separately.[1]
  2. (b) S(5) calls S(4), which calls S(3), S(2) and finally S(1). Five frames are pushed.The descent, with nothing computed yet.[1]
  3. S(1) returns 1 — the base case.This starts the unwinding.[1]
  4. S(2) = 2 + 1 = 3; S(3) = 3 + 3 = 6; S(4) = 4 + 6 = 10; S(5) = 5 + 10 = 15.Returns in reverse order of the calls.[1]
  5. (c) Advantage: the code closely matches the mathematical definition, so it is shorter and clearer.Readability is the usual advantage.[1]
  6. Disadvantage: each call uses a stack frame, so it needs more memory and risks stack overflow for large n.Memory cost is the standard disadvantage.[1]

(a) S(1)=1 and S(n)=n+S(n−1); (b) S(5) = 15; (c) clarity vs stack memory

Q11[2 marks]
Give one situation where recursion is clearly preferable to iteration, and one where iteration is preferable.
Answer

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.

20

Further Programming

Multiple choice · 14

Q1SQL is an example of which paradigm?

  1. Aimperative
  2. Bdeclarative
  3. Clow-level
  4. Dobject-oriented
Show answer

Correct answer: B — declarative

A query states the result required without describing how to obtain it — the defining feature of declarative programming.

Q2Encapsulation means:

  1. Amaking all data public
  2. Bbundling data with its methods and restricting access
  3. Ccopying a class
  4. Drunning code in parallel
Show answer

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:

  1. Ainheritance
  2. Bencapsulation
  3. Cpolymorphism
  4. Dabstraction
Show answer

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:

  1. Apolymorphism
  2. Binheritance
  3. Cencapsulation
  4. Doverloading
Show answer

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:

  1. ATRY
  2. BCATCH
  3. CFINALLY
  4. Dnowhere
Show answer

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:

  1. Aruns too slowly
  2. Bcan hide genuine bugs and loses specificity
  3. Cis not allowed
  4. Dprevents the program running
Show answer

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?

  1. Adeclarative
  2. Blow-level
  3. Cobject-oriented
  4. Dfunctional
Show answer

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:

  1. Ait runs faster
  2. Bthe normal logic stays readable
  3. Cerrors never occur
  4. Dno testing is needed
Show answer

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.

Q9What is the difference between a class and an object?

  1. AThey are the same thing
  2. BA class is a blueprint; an object is one instance built from it
  3. CA class holds data; an object holds methods
  4. DAn object can only exist once per program
Show answer

Correct answer: B — A class is a blueprint; an object is one instance built from it

The class defines the structure and behaviour once. Each object created from it gets its own copy of the data. One Student class can produce a thousand student objects, each with different names and marks.

Q10Why make a field private and expose it through methods?

  1. APrivate fields use less memory
  2. BIt lets the class validate every change and protect its own invariants
  3. CIt makes the program run faster
  4. DThe compiler requires it
Show answer

Correct answer: B — It lets the class validate every change and protect its own invariants

That is encapsulation. If balance can only change through withdraw(), you have exactly one place to enforce "never go below zero". A public field can be corrupted from anywhere, and finding the culprit later is painful.

Q11Circle and Rectangle both extend Shape and both define area(). This is:

  1. AEncapsulation
  2. BPolymorphism
  3. CAbstraction
  4. DComposition
Show answer

Correct answer: B — Polymorphism

Polymorphism means "many forms": one method name resolving to different implementations depending on the actual object type. It is what lets a single loop over a mixed list of shapes call area() on each without checking what type it is.

Q12Which relationship is better modelled by composition than inheritance?

  1. AA Dog is an Animal
  2. BA Car has an Engine
  3. CA Square is a Shape
  4. DA Manager is an Employee
Show answer

Correct answer: B — A Car has an Engine

A car is not a kind of engine — it contains one. Inheritance expresses "is a", composition expresses "has a". Using inheritance for a has-a relationship produces classes that inherit members that make no sense for them.

Q13What is the main benefit of abstraction?

  1. ACode runs faster
  2. BCallers depend on what a class does, not how, so internals can change safely
  3. CIt reduces the number of classes
  4. DIt removes the need for testing
Show answer

Correct answer: B — Callers depend on what a class does, not how, so internals can change safely

Abstraction draws a line between interface and implementation. As long as the public methods keep their promises, you can rewrite the internals completely and every caller keeps working — which is what makes large codebases maintainable.

Q14A subclass provides its own version of a method that already exists in its parent. This is called:

  1. AOverloading
  2. BOverriding
  3. CEncapsulating
  4. DInstantiating
Show answer

Correct answer: B — Overriding

Overriding replaces the inherited behaviour with the subclass's own, using the same name and signature. Overloading is different: it means several methods sharing a name but taking different parameter lists, resolved at compile time.

Exam-style questions · 11

Q1[2 marks]
State the difference between the imperative and declarative paradigms.
Answer

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.

Q2[3 marks]
Explain what is meant by encapsulation and give one benefit of it.
Answer

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.

Q3[2 marks]
Explain what polymorphism means, using an example.
Answer

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.

Q4[6 marks]
(a) State what a try–catch–finally structure is for.
(b) Explain why the finally block is useful when working with files.
(c) Explain why catching all exceptions with a single generic handler is poor practice.
(d) Give one advantage of exception handling over checking every operation with an if statement.
Mark scheme
  1. (a) It separates the normal flow from error handling: risky code goes in TRY, and control passes to a CATCH block if an exception occurs.The separation of normal and error paths is the point.[1]
  2. (b) FINALLY runs whether or not an exception occurred, so the file is closed either way.The "either way" behaviour is what makes it useful.[1]
  3. Without it a file could be left open after an error, locking it or losing unwritten data.A concrete consequence earns the second mark.[1]
  4. (c) Different errors need different responses, and a generic handler treats them identically.Loss of specificity is the core issue.[1]
  5. It can also hide genuine bugs, since an unexpected error is caught and silently ignored rather than being noticed.The masking of programming errors is the stronger half of the answer.[1]
  6. (d) The normal logic stays readable, uncluttered by a check after every operation, and an error can be handled at whatever level makes sense rather than at the point it occurred.Either readability or the level of handling is acceptable.[1]

(a) separates normal and error paths; (b) files close either way; (c) loses specificity and hides bugs; (d) readability

Q5[2 marks]
Give one situation where a low-level paradigm would be chosen over a high-level one, and explain why.
Answer

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.

Q6[2 marks]
Explain the difference between a class and an object.
Answer

A class is the template that defines the attributes and methods. An object is a particular instance of that class, created at run time, with its own values for those attributes.

Q7[2 marks]
State what is meant by encapsulation and give one benefit.
Answer

Attributes are made private and are accessed only through public methods. This prevents other code from setting an attribute to an invalid value.

Q8[3 marks]
Explain the difference between overriding and overloading a method.
Answer

Overriding replaces an inherited method in a subclass with a new version having the same signature. Overloading defines several methods with the same name but different parameter lists in the same class.

Q9[8 marks]
A school system has a base class Person and subclasses Student and Teacher.
  1. Explain what inheritance is and state one advantage of using it here. [3]
  2. Suggest two attributes that belong in Person and one that belongs only in Student. [3]
  3. Explain how polymorphism could be used when printing a list of all people. [2]
Mark scheme
  1. A subclass automatically acquires the attributes and methods of its parent class[1]
  2. Student and Teacher both get name and address without redefining them[1]
  3. Advantage: the shared code is written once, so a change is made in one place[1]
  4. In Person: name[1]
  5. In Person: date of birth or address[1]
  6. In Student only: class or roll number[1]
  7. Each subclass overrides a describe method with its own version[1]
  8. The program calls describe on every item in the list and the correct version runs automatically[1]
Q10[7 marks]
A class BankAccount has a private attribute balance and public methods deposit and withdraw.
  1. Explain why balance is private rather than public. [2]
  2. Describe the validation the withdraw method should perform. [2]
  3. Write pseudocode for the withdraw method. [3]
Mark scheme
  1. Other code cannot change it directly[1]
  2. So every change passes through a method that can validate it, keeping the balance consistent[1]
  3. The amount must be positive[1]
  4. The amount must not exceed the current balance[1]
  5. Method header taking an amount parameter[1]
  6. IF amount > 0 AND amount <= balance THEN subtract and return TRUE[1]
  7. ELSE return FALSE without changing the balance[1]
Q11[5 marks]
A programmer writes Shape s = new Circle(5) where Circle inherits from Shape.
  1. Explain why this statement is allowed. [2]
  2. The Shape class has an abstract method area. Explain what abstract means here and what Circle must do. [3]
Mark scheme
  1. A Circle is a Shape, so an object of the subclass can be held in a variable of the parent type[1]
  2. This lets one variable or array hold objects of several related classes[1]
  3. An abstract method is declared but has no implementation in the base class[1]
  4. No object of the abstract class itself can be created[1]
  5. Circle must provide its own area method, returning π × radius²[1]

These questions come from the A Level Computer Science (9618) lessons — each topic has its own notes, worked examples and an interactive diagram.