Level 2 — RecallHow Computers Work

How Computers Work

30 minutes40 marksprintable — key stays hidden on paper

Difficulty: Level 2 (Recall — definitions, standard problems, short derivations) Time limit: 30 minutes Total marks: 40


Q1. Number system conversions. (6 marks) (a) Convert the decimal number 4545 to binary. (2) (b) Convert the binary number 10110110210110110_2 to decimal. (2) (c) Convert the binary number 10110110210110110_2 to hexadecimal. (2)

Q2. Explain why hexadecimal is commonly used by programmers to represent binary data, rather than plain decimal. Give one concrete reason involving the relationship between bits and hex digits. (3 marks)

Q3. Boolean algebra. (4 marks) (a) State the output of 111 \oplus 1 (XOR) and 101 \oplus 0. (2) (b) A NAND gate is called a "universal gate." State what this means. (2)

Q4. Complete the truth table for the XOR operation and the NOR operation. (4 marks)

AA BB ABA \oplus B A NOR BA \text{ NOR } B
0 0
0 1
1 0
1 1

Q5. Half adder and full adder. (5 marks) (a) Write the Boolean expressions for the Sum and Carry outputs of a half adder with inputs AA and BB. (2) (b) A full adder adds inputs A=1A=1, B=1B=1, and carry-in Cin=1C_{in}=1. State the Sum and Carry-out. (3)

Q6. Flip-flops. (4 marks) (a) What is the primary function of a flip-flop in a digital circuit? (2) (b) In an SR flip-flop, which input combination is considered "forbidden" or invalid, and why? (2)

Q7. Memory hierarchy. (5 marks) List the following in order from fastest/smallest to slowest/largest: RAM, HDD, CPU registers, L1 cache, SSD. Then state the general trade-off relationship between speed and cost per byte. (5 marks)

Q8. The fetch–decode–execute cycle. (4 marks) List the three stages of the cycle in order and give a one-line description of what happens in each. (4 marks)

Q9. CPU and software. (5 marks) (a) Name the CPU component responsible for arithmetic and logic operations. (1) (b) Name the CPU component that coordinates and directs operations. (1) (c) Explain the difference between machine code and assembly language. (3)


End of paper.

Answer keyMark scheme & solutions

Q1. (6 marks)

(a) 4545 to binary: 45=32+8+4+1=101101245 = 32 + 8 + 4 + 1 = 101101_2. Check: 32+8+4+1=4532+8+4+1 = 45. ✓ Answer: 1011012101101_2. (2) — (1 for method, 1 for correct result)

(b) 10110110210110110_2 to decimal: 128+0+32+16+0+4+2+0=182128 + 0 + 32 + 16 + 0 + 4 + 2 + 0 = 182. Answer: 182182. (2)

(c) 10110110210110110_2 to hex: group into nibbles 10110110=B6=B6161011\,0110 = \text{B}\,6 = \text{B6}_{16}. Answer: B616\text{B6}_{16} (= 182182). (2)

Why: positional weights are powers of 2; each group of 4 bits maps to one hex digit.


Q2. (3 marks) Hexadecimal is compact: each hex digit represents exactly 4 bits (one nibble), so one byte = 2 hex digits (1). This makes long binary strings much shorter and easier to read/write without error (1). The conversion between binary and hex is trivial and lossless (grouping bits), unlike decimal which does not align with power-of-2 boundaries (1).


Q3. (4 marks) (a) 11=01 \oplus 1 = 0 (1); 10=11 \oplus 0 = 1 (1). (XOR outputs 1 only when inputs differ.) (b) Universal gate means any Boolean function / any other gate (AND, OR, NOT, etc.) can be built using only NAND gates (2). (Because NAND is functionally complete.)


Q4. (4 marks) — 0.5 per correct cell (8 cells)

AA BB ABA \oplus B AA NOR BB
0 0 0 1
0 1 1 0
1 0 1 0
1 1 0 0

Why: XOR = 1 when inputs differ; NOR = NOT(OR), so 1 only when both are 0.


Q5. (5 marks) (a) Half adder: Sum=AB\text{Sum} = A \oplus B (1); Carry=AB\text{Carry} = A \cdot B (AND) (1). (b) Full adder with A=1,B=1,Cin=1A=1, B=1, C_{in}=1: total =1+1+1=3=112= 1+1+1 = 3 = 11_2. So Sum=1\text{Sum} = 1 (1) and Carry-out=1\text{Carry-out} = 1 (1); correct reasoning 1+1+1=31+1+1=3 (1).


Q6. (4 marks) (a) A flip-flop stores a single bit of information (a stable 0 or 1); it is a basic memory element that holds state until changed (2). (b) In an SR flip-flop the forbidden input is S=1,R=1S=1, R=1 (Set and Reset both high) (1), because it drives both outputs to the same value / produces an undefined (indeterminate) state and violates Q=QQ = \overline{Q'}; the resulting state on release is unpredictable (1).


Q7. (5 marks) Order fastest/smallest → slowest/largest (2 marks, all correct): CPU registers → L1 cache → RAM → SSD → HDD. (Partial: 1 mark if only one adjacent pair swapped.)

Trade-off (3 marks): Faster memory is more expensive per byte and therefore built in smaller quantities; slower memory is cheaper per byte and used in larger capacities (3). Hence the hierarchy balances speed against cost/size.


Q8. (4 marks) — 1 mark per stage named + 1 for full correct ordering

  1. Fetch — retrieve the next instruction from memory (address in the program counter). (1)
  2. Decode — the control unit interprets the instruction and determines the operation/operands. (1)
  3. Execute — the ALU/relevant unit carries out the operation and stores the result. (1) Correct order maintained (1).

Q9. (5 marks) (a) ALU (Arithmetic Logic Unit) (1). (b) Control Unit (1). (c) Machine code is the binary instructions the CPU directly executes (1). Assembly language is a human-readable text form using mnemonics (e.g. MOV, ADD) that maps essentially one-to-one to machine instructions (1) and must be translated (assembled) into machine code before running (1).


[
  {"claim": "45 decimal equals binary 101101", "code": "result = (int('101101',2) == 45)"},
  {"claim": "10110110 binary equals 182 decimal", "code": "result = (int('10110110',2) == 182)"},
  {"claim": "10110110 binary equals hex B6", "code": "result = (format(int('10110110',2),'X') == 'B6')"},
  {"claim": "Full adder 1+1+1 gives sum 1 carry 1", "code": "s=(1+1+1)%2; c=(1+1+1)//2; result = (s==1 and c==1)"},
  {"claim": "XOR column is 0,1,1,0 and NOR column is 1,0,0,0", "code": "xor=[a^b for a in (0,1) for b in (0,1)]; nor=[1-(a|b) for a in (0,1) for b in (0,1)]; result = (xor==[0,1,1,0] and nor==[1,0,0,0])"}
]