Skip to content

← Grade 9 Computing

Exam practice

Every question from the end of every unit, with hints and answers to open. After you check an answer, mark how you did, and come back to the ones you didn’t get.

15 questions

Unit 2 · Data in Depth

a.

Answer these questions.

  • i.What is a number system?
  • ii.Define the base or radix of a number system.
  • iii.Name four number systems, with the base and the digits of each.
  • iv.What is the hexadecimal number system? Write the symbols it uses.
Answer
  • i.A number system is a way of writing numbers with a fixed set of symbols (digits) and rules, in which each digit’s value depends on its place.
  • ii.The base or radix is the number of different digits the system uses; each place is worth the base times the place to its right.
  • iii.Binary, base 2, digits 0 and 1; octal, base 8, digits 0 to 7; decimal, base 10, digits 0 to 9; hexadecimal, base 16, digits 0 to 9 and A to F.
  • iv.Hexadecimal is the base-16 number system. It uses the sixteen symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, where A to F stand for 10 to 15. Each hex digit stands for four bits, so it is used as a short way of writing binary.
b.

Perform these binary additions.

  • i.(11110)₂ + (1001)₂
  • ii.(1010)₂ + (110)₂
  • iii.(100111)₂ + (11010)₂
  • iv.(110001)₂ + (100101)₂
Answer
  • i.30 + 9 = 39: (100111)₂
  • ii.10 + 6 = 16: (10000)₂
  • iii.39 + 26 = 65: (1000001)₂
  • iv.49 + 37 = 86: (1010110)₂

(Check each by changing both numbers and the answer to decimal.)

c.

Perform these binary subtractions and multiplications.

  • i.(1100)₂ − (1001)₂
  • ii.(11101)₂ − (1010)₂
  • iii.(101100)₂ − (10011)₂
  • iv.(1000001)₂ − (10101)₂
  • v.(110)₂ × (11)₂
  • vi.(1011)₂ × (101)₂
Answer
  • i.12 − 9 = 3: (11)₂
  • ii.29 − 10 = 19: (10011)₂
  • iii.44 − 19 = 25: (11001)₂
  • iv.65 − 21 = 44: (101100)₂
  • v.110 + 1100 (110 shifted one place) = (10010)₂. Check: 6 × 3 = 18 = 16 + 2.
  • vi.1011 + 101100 (1011 shifted two places; the 0 in the middle of 101 adds nothing) = (110111)₂. Check: 11 × 5 = 55 = 32 + 16 + 4 + 2 + 1.

(Check each subtraction by adding the answer to the number taken away, and each product in decimal.)

d.

Convert these decimal numbers to binary: i. (56)₁₀ ii. (123)₁₀ iii. (540)₁₀

Answer
  • i.56 → 28 r 0 → 14 r 0 → 7 r 0 → 3 r 1 → 1 r 1 → 0 r 1. From the bottom up: (111000)₂. Check: 32 + 16 + 8 = 56.
  • ii.123 → 61 r 1 → 30 r 1 → 15 r 0 → 7 r 1 → 3 r 1 → 1 r 1 → 0 r 1. (1111011)₂. Check: 64 + 32 + 16 + 8 + 2 + 1 = 123.
  • iii.540 → 270 r 0 → 135 r 0 → 67 r 1 → 33 r 1 → 16 r 1 → 8 r 0 → 4 r 0 → 2 r 0 → 1 r 0 → 0 r 1. (1000011100)₂. Check: 512 + 16 + 8 + 4 = 540.
e.

Convert to decimal: i. (11100111)₂ ii. (763)₈ iii. (B74)₁₆ iv. (DEF)₁₆

Answer
  • i.128 + 64 + 32 + 4 + 2 + 1 = 231
  • ii.7 × 64 + 6 × 8 + 3 = 448 + 48 + 3 = 499
  • iii.11 × 256 + 7 × 16 + 4 = 2,816 + 112 + 4 = 2,932
  • iv.13 × 256 + 14 × 16 + 15 = 3,328 + 224 + 15 = 3,567
f.

Convert: i. (216)₁₀ to octal ii. (1334)₁₀ to octal iii. (225)₁₀ to hexadecimal iv. (2046)₁₀ to hexadecimal

Answer
  • i.216 ÷ 8 = 27 r 0; 27 ÷ 8 = 3 r 3; 3 ÷ 8 = 0 r 3. (330)₈. Check: 3 × 64 + 3 × 8 = 216.
  • ii.1334 ÷ 8 = 166 r 6; 166 ÷ 8 = 20 r 6; 20 ÷ 8 = 2 r 4; 2 ÷ 8 = 0 r 2. (2466)₈. Check: 2 × 512 + 4 × 64 + 6 × 8 + 6 = 1,024 + 256 + 48 + 6 = 1,334.
  • iii.225 ÷ 16 = 14 r 1; 14 ÷ 16 = 0 r 14 = E. (E1)₁₆. Check: 14 × 16 + 1 = 225.
  • iv.2046 ÷ 16 = 127 r 14 = E; 127 ÷ 16 = 7 r 15 = F; 7 ÷ 16 = 0 r 7. (7FE)₁₆. Check: 7 × 256 + 15 × 16 + 14 = 1,792 + 240 + 14 = 2,046.
g.

Convert: i. (11110000111)₂ to hexadecimal ii. (1110010110)₂ to hexadecimal iii. (FACE)₁₆ to binary iv. (A9F)₁₆ to binary

Answer
  • i.Groups of four from the right: 0111 1000 0111 = (787)₁₆.
  • ii.0011 1001 0110 = (396)₁₆.
  • iii.F = 1111, A = 1010, C = 1100, E = 1110: (1111101011001110)₂.
  • iv.A = 1010, 9 = 1001, F = 1111: (101010011111)₂.
h.

Why do computer people use hexadecimal? Give two reasons, and two places where hex numbers are seen.

Answer

Reasons: hex is a short way of writing binary, since each hex digit is exactly four bits, so it is far shorter than binary and easy to change to and from it, a few bits at a time; and a byte is exactly two hex digits, so the bytes of a file or of memory can be read off at a glance, which decimal can’t do.
Places (any two): web colors such as #FF0000; Unicode code points such as U+0928; MAC addresses of network cards; memory addresses and error codes; IPv6 addresses.

i.
  • i.Write −20 in 8-bit two’s complement, showing your steps.
  • ii.What number does the 8-bit two’s complement 10011100 stand for?
  • iii.Work out 50 − 20 by adding 50 and −20 in 8-bit two’s complement.
Answer
  • i.20 = 00010100. Flip: 11101011. Add 1: 11101100. Check: −128 + 64 + 32 + 8 + 4 = −20.
  • ii.−128 + 16 + 8 + 4 = −100.
  • iii.50 = 00110010, −20 = 11101100.

00110010 + 11101100 = 1 00011110. The carry off the left end is dropped, leaving 00011110 = 16 + 8 + 4 + 2 = 30. ✓

j.

Explain why the one Nepali syllable स्त्री takes 18 bytes in UTF-8, while the English word stree takes 5.

Answer

UTF-8 stores code points, not the shapes you see. स्त्री is stored as 6 code points, in the order it is said: स, the halant ◌्, त, the halant ◌्, र and the vowel sign ◌ी. Every Devanagari code point is between U+0900 and U+097F, which is above U+07FF, so UTF-8 stores each in 3 bytes: 6 × 3 = 18 bytes. stree is 5 ASCII letters, each below U+0080, so each takes 1 byte: 5 bytes.

k.

A photo is 4,000 × 3,000 pixels with a color depth of 24 bits.

  • i.How big are its pixels, in MB, uncompressed?
  • ii.Saved as a JPEG it is 3 MB. What is the compression ratio?
  • iii.Name two things JPEG throws away, and say why you don’t notice.
Answer
  • i.4,000 × 3,000 × 24 = 288,000,000 bits = 36,000,000 bytes. 36,000,000 ÷ 1,024 ÷ 1,024 ≈ 34.3 MB.
  • ii.34.3 ÷ 3 ≈ 11 : 1.
  • iii.It keeps color with less detail than brightness (one color for each 2 × 2 square), because eyes see detail in light and dark much better than in color. And it throws away or rounds the finest patterns in each 8 × 8 block, because eyes hardly notice such tiny detail.
l.

A school records its morning assembly: 22,050 samples a second, 16 bits a sample, mono, for 10 minutes.

  • i.How big is the recording uncompressed, in MB?
  • ii.Saved as an MP3 at 64 kbps, how big is it?
Answer
  • i.22,050 × 16 × 1 × 600 = 211,680,000 bits = 26,460,000 bytes. ÷ 1,024 ÷ 1,024 ≈ 25.2 MB.
  • ii.64,000 × 600 = 38,400,000 bits = 4,800,000 bytes. ÷ 1,024 ÷ 1,024 ≈ 4.6 MB, about 5.5 times smaller.
m.

Encode each row with run-length encoding, and say whether it got smaller. Count each pixel as 1 byte, and each run as 2 bytes (a count and a color).

  • i.RRRRRRRRGGGGBBBBBBBB
  • ii.RGRGRGRGRG
Answer
  • i.8R 4G 8B: 3 runs = 6 bytes instead of 20. Smaller, a ratio of about 3.3 : 1.
  • ii.1R 1G 1R 1G 1R 1G 1R 1G 1R 1G: 10 runs = 20 bytes instead of 10. Bigger, twice the size: there are no runs to squeeze.
n.

What is the difference between lossless and lossy compression? Which would you use for each of these, and why? i. a Python program ii. a song for your phone iii. a screenshot of a bank statement iv. a photo for a school’s social media page

Answer

Lossless compression stores the data in fewer bits without losing anything: decompressed, it is exactly the original (ZIP, PNG). Lossy compression throws away detail people won’t notice, so files are much smaller, but the original can never be got back (JPEG, MP3).

  • i.Lossless: a program must stay exactly right; one changed character can stop it working.
  • ii.Lossy (MP3 or AAC): the ear misses what is thrown away, and the file is about ten times smaller.
  • iii.Lossless (PNG): the small numbers and letters must stay sharp and exact.
  • iv.Lossy (JPEG at good quality): it is a photo for people to look at, and a small file loads quickly.
o.

A file holds the 16 letters ABABABABABABABAB.

  • i.Encode it by run-length encoding (a count and a letter for each run, 2 bytes a run). Does it get smaller?
  • ii.Store it with pointers back to earlier text instead. What is stored?
  • iii.What does this tell you about how compression methods find patterns?
Hint

For ii, after the first two letters, everything else is a copy of what came before. A copy may run on into the letters it is making.

Answer
  • i.Every run is 1 letter long: 1A 1B 1A 1B … , 16 runs = 32 bytes instead of 16. It gets twice as big.
  • ii.A, B, then one pointer: go back 2 and copy 14. The copy starts at the first A and keeps going into the letters it has just written, so AB is repeated seven more times. That is 2 letters and 1 pointer instead of 16 letters. (Type the letters into the widget in Lossless: repeats anywhere to check.)
  • iii.Each method finds only its own kind of pattern. Run-length encoding sees only the same value side by side, so it fails here; pointers find any piece that came before, so they shrink it to almost nothing. Where there is no pattern of any kind, as in random letters, nothing shrinks.