This mini-lesson covers OCR 1.4 β Data types, data structures and algorithms, including the Boolean algebra in 1.4.3 that so many candidates skip and then lose marks on.
Work through each screen, answer the questions as you go (some are recall, some are calculations you must actually work out) and collect β stars. Press Start when you're ready.
| Type | Holds | Typical size |
|---|---|---|
| integer | whole numbers | 2 or 4 bytes |
| real / float | numbers with a fractional part | 4 or 8 bytes |
| character | a single symbol | 1 byte (ASCII) |
| string | a sequence of characters | varies |
| Boolean | True or False | 1 bit, usually padded to 1 byte |
ASCII uses 7 bits for 128 characters β English only. Unicode assigns a code point to every character in every script, needing 16 bits or more.
Choose the smallest type that works. Integers are exact; reals are floating point and carry rounding error. Store money as an integer number of pence, never as a real β a fraction of a penny that cannot be represented exactly will, given enough transactions, cost someone real money.
In two's complement the most significant bit carries a negative weight:
To negate: write the positive value, flip every bit, then add 1. So +20 = 00010100 β flip = 11101011 β +1 = 11101100 = β20.
Range in 8 bits: β128 to +127.
Subtraction becomes addition: A β B is computed as A + (βB), so one adder circuit does both jobs. Sign and magnitude is the alternative β the MSB is simply a sign flag β but it has two representations of zero and needs separate subtraction hardware, which is why nobody uses it.
01101101 (109)
+ 00101110 (46)
= 10011011 (155) β carry each 1+1 into the next column
Overflow: the result of that sum, 155, is fine as an unsigned byte β but read as two's complement the same bits mean β101. When a result will not fit the word length, the sign flips and the answer is silently wrong. That is overflow, and it is why the status register has an overflow flag.
Hexadecimal is base 16: digits 0β9, then A=10, B=11, C=12, D=13, E=14, F=15. One hex digit is exactly 4 bits, so a byte is always two hex digits. It is used for memory addresses, colour codes and MAC addresses because it is compact and converts to binary with no arithmetic.
Floating point stores a number as:
The mantissa holds the significant digits and so sets the precision; the exponent places the binary point and so sets the range. For a fixed word length, bits given to one are taken from the other.
Normalisation removes leading redundant bits to maximise precision: a positive normalised mantissa starts 0.1; a negative one starts 1.0. The exponent is adjusted to compensate, so the value never changes.
Mantissa 0.0110, exponent 0011 (= 3).
0.0110 in binary = 0.25 + 0.125 = 0.375. Multiply by 2Β³ = 8 β 3
Normalised, this is 0.1100 Γ 2Β² = 0.75 Γ 4 = 3 β same value, one more bit of precision.
A mask uses AND, OR or XOR with a chosen pattern to isolate or change specific bits:
Shifts: a logical shift left by n multiplies by 2βΏ; a logical shift right by n divides by 2βΏ (discarding the remainder). Bits shifted off the end are lost, and zeros are shifted in.
Why bother? A shift is a single, extremely fast instruction, whereas a general multiply takes several cycles. Masks are how a program packs several flags into one byte and reads them back out β vital in embedded systems and network protocols where every bit counts.
Array vs linked list β the real trade-off: arrays give instant access by index but expensive insertion; linked lists give cheap insertion but force you to walk from the head. Choose on the basis of which operation you will do most often.
| Gate | Output is 1 when⦠|
|---|---|
| NOT Δ | the input is 0 |
| AND A Β· B | both inputs are 1 |
| OR A + B | at least one input is 1 |
| XOR A β B | the inputs differ |
| NAND / NOR | the inverse of AND / OR |
A truth table with n inputs has 2βΏ rows. The laws you must know:
| Law | Identity |
|---|---|
| Commutation | A Β· B = B Β· A A + B = B + A |
| Association | (A Β· B) Β· C = A Β· (B Β· C) |
| Distribution | A Β· (B + C) = AΒ·B + AΒ·C |
| Absorption | A + (A Β· B) = A |
| Double negation | NOT(NOT A) = A |
| De Morgan | NOT(A Β· B) = Δ + BΜ NOT(A + B) = Δ Β· BΜ |
AΒ·B + AΒ·BΜ = A Β· (B + BΜ) = A Β· 1 = A
Two gates become none. B was irrelevant all along.
A Karnaugh map simplifies a function visually. Cells are laid out in Gray code order (00, 01, 11, 10) so adjacent cells differ in exactly one variable.
F = 1 for the minterms 000, 001, 100, 101 (in ABC order).
In all four, B = 0, while A and C each take both values.
A and C vary, so both are eliminated: F = NOT B.
Half adder: Sum = A β B, Carry = A Β· B. It cannot accept a carry in.
Full adder: Sum = A β B β Cα΅’β, and Cβα΅€β = (A Β· B) + (Cα΅’β Β· (A β B)). Chain n of them and you have an n-bit adder.
D-type flip-flop: on the rising edge of the clock, whatever is on D is captured on Q and held. That is one bit of memory β the building block of every register and of SRAM cache.
Tap a term, then tap the group it belongs to.
Tap an item on the left, then its partner on the right.
Types: integer Β· real Β· character Β· string Β· Boolean Β· ASCII (7-bit) vs Unicode Β· store money in pence
Two's complement: MSB is negative Β· negate = flip and add 1 Β· 8-bit range β128 to +127 Β· subtraction becomes addition Β· overflow flips the sign
Hex & floats: one hex digit = 4 bits Β· 3F = 63 Β· mantissa Γ 2^exponent Β· normalise: positive starts 0.1, negative 1.0
Bitwise: AND masks bits out, OR sets, XOR flips Β· LSL n = Γ 2βΏ, LSR n = Γ· 2βΏ
Structures: array O(1) access Β· linked list O(1) insert Β· stack LIFO Β· queue FIFO Β· BST O(log n) Β· hash table O(1) average
Boolean: 2βΏ truth-table rows Β· AΒ·B + AΒ·BΜ = A Β· De Morgan Β· Karnaugh maps need Gray code Β· half/full adder Β· D-type flip-flop
That is the whole of OCR 1.4 β including the Boolean algebra of 1.4.3. Press Finish to see your score.
You've worked through Data types, structures & Boolean algebra for OCR A-level Computer Science (H446). π
Your stars: 0 / 0
Next: test yourself in the Evaluate stage Confidence Quiz, then lock it in with Verify.