OCR H446 A Level Computer Science · 1.4 Data Types, Data Structures and Boolean Algebra

Stretch tasks Data Types, Number Systems and Boolean Algebra

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

This or That

Pixel the cat asks 8 questions. Each has two answers: pick the right one.

  • Two answers to every question
  • A fish treat for every right answer
  • Streaks win Pixel shades, then a party hat

About 4 minutes

Task 3

Memory Match

Flip the cards two at a time to match each term card to its meaning card.

  • 12 cards: each term has a meaning
  • One peek at every card
  • Combo points for pairs found in a row

6 pairs, about 4 minutes

Task 4

Sort It

Sort each statement into the right box, like the tick box tables in the exam.

  • 8 cards to sort into 4 boxes
  • Drag a card, tap a box or press its number
  • Combo points for cards sorted in a row

8 cards, about 4 minutes

Task 5

Code Word

Guess the lesson's secret words. Every guess shows which letters are right.

  • A clue for every word
  • Tiles turn green, amber or grey after each guess
  • Fewer guesses win more points

3 words, about 4 minutes

Task 7

Bug Hunt

Two statements are true and one has a bug. Catch the bug before it gets away.

  • Three statements in every round
  • Tap the one with the mistake
  • Streaks win bonus points

5 rounds, about 4 minutes

Brain games

Train your brain on this lesson

Logic, memory and speed, built from this lesson's own key ideas. Win up to three diamonds in each game.

Logic

Odd One Out

Four tiles: three share a link and one does not. Spot the odd one out, then see what links the rest.

  • Three belong together, one does not
  • A hint shows the link, for fewer points
  • Quick answers and streaks win more

8 rounds, about 3 minutes

Memory

Memory Flash

Study the term cards, then they flip over. Find the card that goes with each clue, from memory.

  • Three levels: 3, 4 and 6 cards
  • Two tries to find each card
  • Streaks win bonus points

3 levels, about 4 minutes

Speed

Fact or Fib

Statements fly in one at a time. Is each one a fact or a fib? Decide fast.

  • Swipe, tap or use the arrow keys
  • Every fib comes with its fix
  • Streaks multiply your points

12 statements, about 3 minutes

The final challenge

City Run

Race a robot cat on inline skates through a neon cyber city, from Neon Station to the Hyper Tunnel. Every question is a row of neon gates across the tracks: skate through the one with the right answer, dodge the trains and barriers, and grab diamonds.

  • 20 questions from this lesson, in four parts of the city
  • Swipe, tap or use the arrow keys
  • Dodge trains and holograms, and jump crates and cones

20 questions, about 6 minutes

Bonus challenge

Neon Roll

Roll a glowing ball down an endless neon slope, past towers lit up with neon signs of Pixel the cat. Steer, jump the gaps and dodge the blocks. Questions from this lesson wait at gates along the way: every right answer keeps the ball rolling.

  • Questions from this lesson at every gate
  • Hold the arrow keys or a side of the slope to steer
  • 8 right answers win two diamonds, 15 win three

Endless, about 5 minutes

The games need JavaScript. Every question is below, with the answers at the end.

Read the lesson: Data Types, Number Systems and Boolean Algebra

Data Types, Number Systems and Boolean Algebra: the questions

Quiz Challenge, round 1: Quiz Blitz

  1. What is the place value of the most significant bit in 8 bit two's complement?

    • Minus 1
    • 256
    • Minus 128
    • 128
  2. Which steps turn 00010100 into its negative in two's complement?

    • Invert every bit, then add one
    • Invert every bit only
    • Add one, then invert every bit
    • Shift every bit left once
  3. For a fixed number of bits, more mantissa bits give more precision but less range.

    • True
    • False
  4. Why is a floating point number normalised?

    • To turn it into an integer
    • To store it with the greatest possible precision
    • To make it positive
    • To remove the exponent
  5. Which TWO of these mantissas are normalised?

    Tick 2.

    • 1.0010
    • 0.0110
    • 1.1010
    • 0.1101
  6. Which bitwise operation with 00001111 keeps only the low four bits of a byte?

    • AND
    • OR
    • XOR
    • NOT
  7. What does shifting a binary number left by two places do?

    • Multiplies it by 4
    • Multiplies it by 2
    • Divides it by 4
    • Adds 2 to it
  8. De Morgan's laws say (A.B)' is the same as A' . B'.

    • True
    • False
  9. Simplify A + A.B using the absorption law.

  10. Put the steps to simplify A.B + A.B' in order.

    Number these 1 to 3.

    • A.1
    • A
    • A.(B + B')
  11. In a Karnaugh map, which group sizes are allowed?

    • 3, 6 or 9 cells
    • 1, 2, 4 or 8 cells
    • Any number of cells
    • Only pairs of cells
  12. Why do engineers simplify Boolean expressions?

    • It makes the truth table longer
    • Fewer gates mean lower cost, less power and less delay
    • Simpler expressions give different outputs
    • Logic gates cannot carry out NOT

Quiz Challenge, round 2: Quick Fire

  1. Explain how to turn 20 into minus 20 in 8 bit two's complement. [2 marks]

  2. Explain the trade off between range and precision in floating point. [2 marks]

  3. Explain why simplifying a Boolean expression is useful when building a circuit. [2 marks]

  4. Explain why floating point cannot store 0.1 exactly. [2 marks]

Quiz Challenge, round 3: Big Think

  1. Describe how a floating point number is stored, and why it is normalised. [6 marks]

  2. Explain what AND, OR and XOR masks do to a binary value, with a use for each. [4 marks]

This or That: tick the right answer

  1. Which representation lets hardware subtract using only an adder?

    • Sign and magnitude
    • Two's complement
  2. The total stays the same but the exponent gets more bits. What improves?

    • Precision
    • Range
  3. Which is faster and keeps the same absolute accuracy everywhere?

    • Floating point
    • Fixed point
  4. Which operation toggles chosen bits?

    • AND
    • XOR
  5. What is A . A' always equal to?

    • A
    • 0
  6. What is A + 1 always equal to?

    • A
    • 1
  7. Which is (A + B)' by De Morgan's law?

    • A' . B'
    • A' + B'
  8. Why do financial systems store money as whole pence?

    • Floating point cannot store 0.1 exactly
    • Integers take more memory

Memory Match: match each term to its meaning

TermMeaning
A Mantissa1 Time for a signal to pass through the gates
B Exponent2 The significant digits of a floating point number
C Bit mask3 Break the bar and change the operator
D De Morgan's laws4 Grid for simplifying by grouping adjacent ones
E Karnaugh map5 A pattern used with AND or OR to pick out bits
F Propagation delay6 The power of two the mantissa is multiplied by

Sort It: tick one box in each row

Which Boolean law does each identity show?

StatementIdentityInverseAbsorptionDe Morgan's
A + A.B = A
A . A' = 0
A + 0 = A
(A.B)' = A' + B'
A + A' = 1
(A + B)' = A' . B'
A . (A + B) = A
A . 1 = A

Code Word: write the word that fits each clue

  1. The part of a floating point number that holds its significant digits. (8 letters)

  2. The power of two that sets where the binary point goes. (8 letters)

  3. Four bits, which is one hexadecimal digit. (6 letters)

Link Up: find the three groups

These 12 tiles make 3 groups of 4. Write each group in the table, and what links its tiles.

  • De Morgan's
  • Groups may overlap
  • Wrap around edges
  • Left shift
  • OR
  • Powers of two
  • Identity
  • Distributive
  • XOR
  • Absorption
  • AND
  • Group only 1s

Bug Hunt: tick the statement that is wrong

In each set, two statements are true and one has a mistake in it.

    • In 8 bit two's complement the most significant bit is worth minus 128.
    • To negate a two's complement number, invert the bits and add one.
    • The range of 8 bit two's complement is minus 127 to 128.
    • More exponent bits give a larger range.
    • A normalised positive mantissa starts with 01.
    • Normalising a mantissa reduces its precision.
    • OR with 10000000 forces the top bit on.
    • AND with 00001111 keeps only the low four bits.
    • Shifting a binary number right by one place doubles it.
    • A + A' always equals 1.
    • A . 0 always equals 0.
    • A + A always equals 2A.
    • Groups in a Karnaugh map may wrap around the edges.
    • Groups in a Karnaugh map must never overlap.
    • Karnaugh map groups must contain 1, 2, 4 or 8 cells.

Brain game: Odd One Out

Three tiles in each set share a link. Tick the odd one out, then write what links the other three.

    • De Morgan's
    • Identity
    • Distributive
    • Group only 1s

    What links the other three?

    • Left shift
    • XOR
    • Absorption
    • AND

    What links the other three?

    • De Morgan's
    • Groups may overlap
    • Wrap around edges
    • Powers of two

    What links the other three?

    • Left shift
    • Identity
    • Distributive
    • Absorption

    What links the other three?

    • Groups may overlap
    • Left shift
    • OR
    • AND

    What links the other three?

    • De Morgan's
    • Groups may overlap
    • Powers of two
    • Group only 1s

    What links the other three?

Brain game: Memory Flash, on paper

Which term means this? Write your answer from memory.

  1. The power of two the mantissa is multiplied by

  2. Time for a signal to pass through the gates

  3. The significant digits of a floating point number

  4. Break the bar and change the operator

  5. Grid for simplifying by grouping adjacent ones

  6. A pattern used with AND or OR to pick out bits

Brain game: Fact or Fib

Tick Fact if the statement is true and Fib if it is not.

  1. OR with 10000000 forces the top bit on.

    • Fact
    • Fib
  2. Normalising a mantissa reduces its precision.

    • Fact
    • Fib
  3. A + A always equals 2A.

    • Fact
    • Fib
  4. A . 0 always equals 0.

    • Fact
    • Fib
  5. The range of 8 bit two's complement is minus 127 to 128.

    • Fact
    • Fib
  6. Groups in a Karnaugh map may wrap around the edges.

    • Fact
    • Fib
  7. A + A' always equals 1.

    • Fact
    • Fib
  8. AND with 00001111 keeps only the low four bits.

    • Fact
    • Fib
  9. Shifting a binary number right by one place doubles it.

    • Fact
    • Fib
  10. In 8 bit two's complement the most significant bit is worth minus 128.

    • Fact
    • Fib
  11. Groups in a Karnaugh map must never overlap.

    • Fact
    • Fib
  12. De Morgan's laws say (A.B)' is the same as A' . B'.

    • Fact
    • Fib

City Run

City Run is a race through a neon cyber city, played on screen. It asks 20 of the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.

Neon Roll

Neon Roll is a ball rolling down an endless neon slope, played on screen. Every right answer keeps it rolling. It asks the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.

Answers

Round 1: Quiz Blitz

  1. Minus 128 The most significant bit carries a negative place value, so 10000000 is minus 128.
  2. Invert every bit, then add one Inverting gives 11101011, and adding one gives 11101100, which is minus 20.
  3. True Bits moved to the mantissa improve precision but leave fewer for the exponent, which sets the range.
  4. To store it with the greatest possible precision A normalised mantissa starts 01 or 10, so no bits are wasted on repeated leading digits.
  5. 0.1101; 1.0010 A normalised positive mantissa starts 0.1 and a negative one starts 1.0. A leading 00 or 11 wastes a bit.
  6. AND ANDing with 0 clears a bit and ANDing with 1 keeps it, so the mask keeps the low four bits.
  7. Multiplies it by 4 Each place left doubles the value, so two places multiply by 4, as long as no 1s are lost off the end.
  8. False Break the bar and change the operator: (A.B)' equals A' + B'.
  9. a Absorption: A + A.B = A. If A is true the whole expression is already true.
  10. A.(B + B') → A.1 → A Factor out A by the distributive law, B + B' = 1 by the inverse law, then A.1 = A by the identity law.
  11. 1, 2, 4 or 8 cells Groups must be rectangles whose size is a power of two, and as large as possible.
  12. Fewer gates mean lower cost, less power and less delay The same logic with fewer gates is cheaper, cooler, smaller and faster.

Round 2: Quick Fire

    • Invert every bit
    • Then add one
    Model answer

    Write 20 as 00010100, invert every bit to get 11101011, then add one to get 11101100.

    • More mantissa bits give more precision
    • More exponent bits give more range
    • The total is fixed, so improving one worsens the other
    Model answer

    With a fixed number of bits, giving more bits to the mantissa increases precision but leaves fewer for the exponent, which reduces the range.

    • It needs fewer logic gates
    • So the circuit is cheaper, uses less power, makes less heat and is faster
    Model answer

    A simpler expression needs fewer logic gates, so the circuit is cheaper, uses less power, produces less heat and has a shorter propagation delay.

    • 0.1 is a recurring fraction in binary
    • The mantissa has a limited number of bits, so the value is rounded
    Model answer

    In binary 0.1 is a recurring fraction that never ends, like one third in denary, and the mantissa has only a limited number of bits, so the value has to be rounded.

Round 3: Big Think

    • It is stored as a mantissa and an exponent
    • The value is the mantissa times 2 to the power of the exponent, which moves the binary point
    • Both parts are in two's complement
    • A normalised mantissa starts 01 when positive or 10 when negative
    • Normalising gives the greatest precision
    • No bits are wasted on leading repeated digits
    • Each number has only one representation
    Model answer

    A floating point number is stored as a mantissa and an exponent, both in two's complement. The value is the mantissa multiplied by 2 to the power of the exponent, so the exponent moves the binary point. The mantissa is normalised so that it starts with 01 for a positive number or 10 for a negative one. This means no bits are wasted on leading repeated digits, which gives the greatest possible precision, and each number has only one representation.

    • AND keeps the bits where the mask has a 1 and clears the rest
    • OR sets chosen bits to 1
    • XOR toggles chosen bits
    • XORing twice restores the value, so it works as a simple cipher
    Model answer

    ANDing with a mask keeps the bits where the mask has a 1 and clears the rest, which can isolate the low nibble. ORing with a mask sets chosen bits to 1, such as forcing the top bit on. XORing with a mask toggles chosen bits, and doing it twice gives the original back, which makes it a simple reversible cipher.

This or That

  1. Two's complement In two's complement, subtracting is adding the negative, so the hardware needs only an adder.
  2. Range The exponent sets how far the point can move, so more exponent bits widen the range but leave fewer for the mantissa.
  3. Fixed point Fixed point keeps the binary point in one place, which is fast and uniform, but its range is far smaller.
  4. XOR XOR with a 1 flips a bit and with a 0 leaves it, so XORing twice restores the original.
  5. 0 Inverse law: something and its opposite can never both be true.
  6. 1 Null law: OR with a true input is always true.
  7. A' . B' Break the bar and change the operator, so the OR becomes an AND.
  8. Floating point cannot store 0.1 exactly Fractions like 0.1 recur in binary, so floating point rounds them. Counting whole pence avoids rounding errors.

Memory Match

  • A 2 Mantissa: The significant digits of a floating point number
  • B 6 Exponent: The power of two the mantissa is multiplied by
  • C 5 Bit mask: A pattern used with AND or OR to pick out bits
  • D 3 De Morgan's laws: Break the bar and change the operator
  • E 4 Karnaugh map: Grid for simplifying by grouping adjacent ones
  • F 1 Propagation delay: Time for a signal to pass through the gates

Sort It

  1. Absorption A + A.B = A If A is true the whole thing is true, so A.B adds nothing: absorption.
  2. Inverse A . A' = 0 A value and its opposite can never both be true: the inverse law.
  3. Identity A + 0 = A ORing with false leaves A unchanged: the identity law.
  4. De Morgan's (A.B)' = A' + B' Break the bar and change AND to OR: De Morgan's law.
  5. Inverse A + A' = 1 A value or its opposite is always true: the inverse law.
  6. De Morgan's (A + B)' = A' . B' Break the bar and change OR to AND: De Morgan's law.
  7. Absorption A . (A + B) = A Whenever A is true, A + B is true too, so the result is just A: absorption.
  8. Identity A . 1 = A ANDing with true leaves A unchanged: the identity law.

Code Word

  1. MANTISSA The part of a floating point number that holds its significant digits.
  2. EXPONENT The power of two that sets where the binary point goes.
  3. NIBBLE Four bits, which is one hexadecimal digit.

Link Up

  • Boolean laws Identity; Absorption; Distributive; De Morgan's
  • Bitwise operations AND; OR; XOR; Left shift
  • Karnaugh map rules Group only 1s; Powers of two; Groups may overlap; Wrap around edges

Bug Hunt: the wrong statement, and why

  1. The range of 8 bit two's complement is minus 127 to 128. It is minus 128 to 127. There is one more negative value because zero uses a positive pattern.
  2. Normalising a mantissa reduces its precision. Normalising removes wasted leading bits, so it gives the greatest possible precision.
  3. Shifting a binary number right by one place doubles it. A right shift halves the number, losing the bit shifted out. A left shift doubles it.
  4. A + A always equals 2A. By the idempotent law A + A = A. In Boolean algebra a value ORed with itself is unchanged.
  5. Groups in a Karnaugh map must never overlap. Groups may overlap. Making each group as large as possible matters more.

Odd One Out

  1. Group only 1s is the odd one out: it goes with Karnaugh map rules. The other three: Boolean laws.
  2. Absorption is the odd one out: it goes with Boolean laws. The other three: Bitwise operations.
  3. De Morgan's is the odd one out: it goes with Boolean laws. The other three: Karnaugh map rules.
  4. Left shift is the odd one out: it goes with Bitwise operations. The other three: Boolean laws.
  5. Groups may overlap is the odd one out: it goes with Karnaugh map rules. The other three: Bitwise operations.
  6. De Morgan's is the odd one out: it goes with Boolean laws. The other three: Karnaugh map rules.

Memory Flash

  1. Exponent The power of two the mantissa is multiplied by
  2. Propagation delay Time for a signal to pass through the gates
  3. Mantissa The significant digits of a floating point number
  4. De Morgan's laws Break the bar and change the operator
  5. Karnaugh map Grid for simplifying by grouping adjacent ones
  6. Bit mask A pattern used with AND or OR to pick out bits

Fact or Fib

  1. Fact OR with 10000000 forces the top bit on.
  2. Fib Normalising a mantissa reduces its precision. The fix: Normalising removes wasted leading bits, so it gives the greatest possible precision.
  3. Fib A + A always equals 2A. The fix: By the idempotent law A + A = A. In Boolean algebra a value ORed with itself is unchanged.
  4. Fact A . 0 always equals 0.
  5. Fib The range of 8 bit two's complement is minus 127 to 128. The fix: It is minus 128 to 127. There is one more negative value because zero uses a positive pattern.
  6. Fact Groups in a Karnaugh map may wrap around the edges.
  7. Fact A + A' always equals 1.
  8. Fact AND with 00001111 keeps only the low four bits.
  9. Fib Shifting a binary number right by one place doubles it. The fix: A right shift halves the number, losing the bit shifted out. A left shift doubles it.
  10. Fact In 8 bit two's complement the most significant bit is worth minus 128.
  11. Fib Groups in a Karnaugh map must never overlap. The fix: Groups may overlap. Making each group as large as possible matters more.
  12. Fib De Morgan's laws say (A.B)' is the same as A' . B'. The fix: Break the bar and change the operator: (A.B)' equals A' + B'.