Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Huffman versus ASCII savings calculation

Q09.2 3 marks

Table 1 shows the Huffman codes for the characters used in the string HESELLSSEASHELLASHES.

Table 1
CharacterCharacter frequencyHuffman code
S611
E510
L400
H3011
A2010
20

Calculate how many bits would be saved if the string HESELLSSEASHELLASHES was encoded using the Huffman codes shown in Table 1, rather than using ASCII.

You should show your working.

Write your answer first. You can study the marking guidance whenever you need it.

Study the marking See what earns credit and compare it with a full-mark answer.

Marking points

  1. 1 Calculates or clearly attempts the Huffman total from character frequencies and code lengths.
  2. 2 Calculates or clearly attempts the 7-bit ASCII total for 20 characters.
  3. 3 Subtracts Huffman bits from ASCII bits to find the saving.

Full-mark answer

Huffman: (6×2) + (5×2) + (4×2) + (3×3) + (2×3) = 45 bits. ASCII: 20×7 = 140 bits. Bits saved = 140−45 = 95 bits.

Why this answer loses marks

I calculated the Huffman total and called it the saving.

A saving is a comparison: calculate the ASCII baseline too, then take the difference between the totals.