01 · Exam map course.json · brief
| Assessment | Weight | What matters here |
|---|---|---|
| Final Exam | 50% | Modules 1–4, 6–11; Inspera IIB Mode D; 36 questions / 50 marks |
| Mid-Semester Test | 20% | Earlier modules; Module 5 belongs here, not the final |
| Assignments | 20% | Practical grouping |
| Essays | 8% | |
| Tutorials | 2% |
“An A4-cheat sheet (typed or handwritten) can be brought into the exam hall.” (COMPSCI 110 exam revision slides, Semester Two 2026)
Scope Final weighting: OS 8 marks; Compilers 7; Security 6; Turing 6; Networks 5; AI 5; Binary 4; Logic, Organisation and Assembly 3 each. Spend time in that order, but bank every mechanical mark.
02 · Binary toolkit M1 · CH 1
k distinct patterns need ⌈log₂k⌉ bits
N address bits select 2ᴺ cells
| Task | Procedure | Check |
|---|---|---|
| Decimal → binary | Repeatedly ÷2; record remainder; read bottom-up | Odd ends 1; even ends 0 |
| Fraction → binary | Repeatedly ×2; record integer parts top-down | 0.1875₁₀ = 0.0011₂ |
| Shift | Left one place ×2; right one place ÷2 | Bits falling off are lost |
| Fixed-width sum | Add right-to-left; 1+1 writes 0, carries 1 | Overflow when result cannot fit |
Signed representations
| Form | Negative | n-bit range / zero |
|---|---|---|
| Sign-magnitude | Flip sign bit | ±(2ⁿ⁻¹−1); two zeros |
| One's complement | Invert all bits | ±(2ⁿ⁻¹−1); two zeros |
| Two's complement | Invert + 1 | −2ⁿ⁻¹…2ⁿ⁻¹−1; one zero |
Fix width → invert b → carry-in 1 → add → discard carry out.
03 · Logic → circuit M2 · CH 2
| A B | AND | OR | NAND | NOR |
|---|---|---|---|---|
| 0 0 | 0 | 0 | 1 | 1 |
| 0 1 | 0 | 1 | 1 | 0 |
| 1 0 | 0 | 1 | 1 | 0 |
| 1 1 | 1 | 1 | 0 | 0 |
NOT flips 0↔1. NAND and NOR are functionally complete; tie their inputs together to make NOT. An n-input table has 2ⁿ rows.
¬(A · B) = ¬A + ¬B
Hardware rules
| Element | Inputs → outputs / rule |
|---|---|
| Full adder | aᵢ,bᵢ,cᵢ → sum sᵢ and carry cᵢ₊₁; chain carry to next bit |
| Subtract | Invert b and set initial carry-in 1 |
| Multiplexor | 2ᴺ inputs, N selectors, 1 output |
| Decoder | N inputs, 2ᴺ outputs |
| SR latch | 00 hold; 10 set; 01 reset; 11 forbidden |
Exam move From a supplied truth table: circle every output-1 row; write all variables in each AND term; bar only the 0 inputs; OR every term. Simplify only if asked.
04 · Stored-program machine M3 · CH 3
| Register | Role |
|---|---|
| PC | Address of next instruction |
| IR | Instruction now executing |
| MAR | Address accessed: the “where” |
| MDR | Data fetched/stored: the two-way “what” |
Von Neumann: one memory holds instructions and data; subsystems are Memory, I/O, ALU and Control Unit; CPU = ALU + CU. Shared sequential traffic causes the bottleneck. Fetch preserves; store overwrites.
05 · Assembly / machine code M4 · CH 4
| Instruction | Opcode | Effect |
|---|---|---|
| LOAD X | 0000 | CON(X) → R |
| STORE X | 0001 | R → CON(X) |
| ADD X | 0011 | R + CON(X) → R |
| SUBTRACT X | 0101 | R − CON(X) → R |
| COMPARE X | 0111 | Set GT/EQ/LT flags |
| HALT | 1111 | Stop; address 000…0 |
Use supplied Figure 6.5: lookup → 12-bit address → concatenate → hex nibbles. Arithmetic uses one register R and 16-bit two's complement.
Desk-check / assemble
- After every line record R, changed memory and GT/EQ/LT.
- .BEGIN/.END/.DATA are directives; LABEL: .DATA 0 binds an address.
- Pass 1 builds label→address; pass 2 inserts opcodes/addresses and emits words. This resolves forward labels.
Trap Do not “remember” an opcode when Figure 6.5 is supplied. Read it; then keep opcode in the top nibble and pad the operand to exactly 12 bits.
06 · Network calculations M6 · CH 6
distance d and signal speed s: d_prop = d/s
s ≈ 2×10⁸ m/s; convert Mbit→bits and km→m first.
| Contrast | A | B |
|---|---|---|
| Switching | Packet: dynamic; queue/drop | Circuit: fixed reserved rate |
| Path action | Forwarding: local table | Routing: network path |
| Delay test | Bigger packet ↑ d_trans | Longer link ↑ d_prop |
07 · Compiler decision chain M7 · CH 7 · 7 marks
| Phase | Input → output | Does / does not |
|---|---|---|
| I Lexical | characters → tokens | Longest valid token; discards whitespace/comments; does not check syntax |
| II Parsing | tokens + grammar → parse tree | Checks syntactic form using BNF productions |
| III Semantic + generation | tree + records → instructions | Types, names, addresses and meaning; emits code |
| IV Optimisation | code → improved code | Improves time or space without changing meaning |
Tokenise under pressure
- Scan left→right. Take the longest valid token.
- Classify: keyword; identifier/symbol; operator; bracket; number; literal; terminator/symbol.
- Discard spaces and comments. == is one operator token and differs from assignment =.
- Count the list. An illegal arrangement still tokenises; the parser rejects its grammar later. A misplaced else remains a keyword.
| Source | Class |
|---|---|
| if | keyword |
| ( ) | brackets |
| a, b, answer | symbols / identifiers |
| ==, = | operators; each is one token |
| 42 | number |
| ; | symbol / terminator |
BNF: productions expand non-terminals into terminals/non-terminals. A parse tree is valid only if its leaves match the token stream and its root reaches the grammar's goal symbol. Syntax asks whether the form is legal; semantics asks whether that legal form makes sense.
high-level → many machine instructions; lexical + syntax + meaning
Mark check If the prompt says “scanner”, do not repair syntax. If it says “parser”, use the supplied grammar. If it says “semantic”, discuss meaning/type/name records, not punctuation.
09 · OS scheduling M8 · CH 8 · 8 marks
| Policy | Rule | Consequence |
|---|---|---|
| FCFS | Longest-waiting process runs to completion | Simple; long first job causes convoy effect |
| Round-Robin | Run ≤ quantum; unfinished job is preempted to queue tail | Responsive/fair; more switches |
2 read each completion time
3 if all arrive at 0: waiting = completion − burst
4 average = Σ waiting / process count
larger slice ↑ efficiency but ↓ responsiveness; tiny slice wastes time switching.
A context switch saves PC, registers and resource handles, then loads the next process. Useful work pauses. If arrival times are not all zero, do not use the shortened waiting formula without accounting for arrival.
OS managers: process, memory, device, file and network managers plus the command interpreter. The ready queue holds runnable processes; the waiting queue holds processes blocked on an event or I/O.
Deadlock decision
| RAG test | Conclusion |
|---|---|
| One unit per resource + cycle | Deadlock |
| Multiple units + cycle | Necessary, not sufficient; check whether any process can still finish |
| No cycle | No deadlock |
Trap A process merely waiting for I/O is not deadlocked. Deadlock is permanent circular waiting: each holds something the next needs and none can proceed.
10 · Cryptography chooser M9 · CH 9 · 6 marks
| Axis | Choose / remember |
|---|---|
| Processing | Block: fixed block/diffusion. Stream: elementwise. |
| Keys | Symmetric: one shared secret. Asymmetric: public/private pair. |
| Systems | DES 56/64; 3DES ≈168; AES keys 128/192/256, block 128. RSA/Diffie–Hellman are public-key. |
| Certificate | Trusted binding: identity ↔ public key. |
encrypt C = V·M mod 26
decrypt V = C·M′ mod 26, where M·M′ = I mod 26
Caesar: 25 shifts + preserved frequencies ⇒ brute force/frequency attack. Matrix blocks add diffusion.
11 · Turing trace M10 · CH 10 · 6 marks
- Record state + symbol; choose the unique matching rule.
- Write field 3; go to state 4; move field 5.
- No match ⇒ HALT; repeating a configuration indicates a loop.
Valid: no duplicate (state,symbol) left sides. Church–Turing: any effectively computable function is Turing-computable; thesis, not theorem.
12 · AI concept distinctions M11 · CH 11 · 5 marks
| Concept | Discriminator |
|---|---|
| Turing test | Text imitation; judge cannot reliably distinguish person/machine. |
| Winograd | Pronoun needs commonsense; wording can flip referent. |
| Neural net | Layered units + weighted links. |
| Back-propagation | Error moves backward to adjust weights; no arithmetic here. |
Trap Turing tests behaviour, not inner mechanism; Winograd tests meaning, not grammar alone.