Skip to the worksheet
Revision Library
Choose a subject

Data Representation: Images, Sound and Compression - Worksheets, Questions and Revision

15 original exam-style questions - 9 pages of questions with a full mark scheme - free printable PDF.

Grades 1-9

This topic is chapter 4 of GCSE Computer Science Topic Workbook 2 and chapter 14 of GCSE Computer Science 10-Minute Tests.

Revision Library
revisionlibrary.co.uk
GCSE · Data Representation

2.6 Data Representation: Images, Sound and Compression

OCR J277 · Calculators not allowed · about 95 minutes
Total Marks
Name: _______________________________    Date: ____ / ____ / ______
Answer ALL questions. Show all your working.
1
Colour depth affects how many different colours a bitmap image can display.
(a)Define the term 'colour depth'.(1)
(b)An image uses a colour depth of 4 bits per pixel. Calculate the maximum number of different colours that can be represented.(2)
(c)Circle the letter next to the colour depth that would allow an image to store the greatest number of different colours.(1)
  • A) 1 bit
  • B) 2 bits
  • C) 4 bits
  • D) 8 bits
(Total for Question 1 is 4 marks)
2
An image editing program uses a palette of 32 different shades of grey. Each shade is given an index number, which is stored using binary.
(a)Calculate the minimum number of bits needed to store a palette index for one of the 32 shades. Show your working.(2)
(b)Convert the denary palette index 19 into binary, using the number of bits found in part (a).(2)
(c)One pixel stores the binary value 11010 as its palette index. Convert this binary value to hexadecimal.(2)
(Total for Question 2 is 6 marks)
3
A bitmap image is 320 pixels wide and 240 pixels high. Each pixel is stored using a colour depth of 8 bits.
(a)State the number of different colours that a colour depth of 8 bits can represent.(1)
(b)Show that the uncompressed image requires 614400 bits of storage.(2)
(c)Calculate the size of the uncompressed image in kilobytes (KB). Use 1 byte = 8 bits and 1 KB = 1000 bytes.(2)
(Total for Question 3 is 5 marks)
4
Sound is recorded by sampling an analogue sound wave at regular intervals.
(a)Define the term 'sample rate'.(1)
(b)Define the term 'bit depth' in the context of sound recording.(1)
(c)State the effect on the recorded sound of increasing the sample rate used.(1)
(d)State one drawback of increasing the sample rate.(1)
(Total for Question 4 is 4 marks)
5
A mono sound clip is recorded with a sample rate of 8000 Hz and a bit depth of 8 bits. The clip lasts 3 seconds.
(a)Calculate the total number of samples taken during the recording.(2)
(b)Calculate the file size of the recording in bits.(2)
(c)Calculate the file size of the recording in kilobytes (KB). Use 1 byte = 8 bits and 1 KB = 1000 bytes.(2)
(Total for Question 5 is 6 marks)
6
A sound engineer is deciding on recording settings for a podcast that will be streamed to mobile phones.
(a)Explain the effect of recording in stereo instead of mono on the file size of the podcast.(2)
(b)Explain why the sound engineer might choose a lower bit depth for the podcast than a professional music studio would use for a music recording.(2)
(Total for Question 6 is 4 marks)
7
A single row of a black and white bitmap image is 12 pixels wide, shown below (W = white pixel, B = black pixel):
W W W W W B B B W W W W
(a)State what run-length encoding (RLE) is used for.(1)
(b)Use run-length encoding to encode the row of pixels above. Give your answer in the form (run length)(colour).(2)
(c)State one type of image for which RLE would achieve a high compression ratio, and one type for which it would not.(2)
(Total for Question 7 is 5 marks)
8
A row of pixels has been run-length encoded as: 6W 2B 6W
The original (uncompressed) row used 1 byte to store the colour of each pixel. The encoded version above uses 2 bytes for each run (1 byte for the run length number and 1 byte for the colour letter).
(a)Decode this run-length encoded data to show the original row of pixels.(2)
(b)Calculate the compression ratio of the encoded row compared to the original uncompressed row, giving your answer in the form n:1 (original size : encoded size).(3)
(Total for Question 8 is 5 marks)
9
A text file contains the following phrase, which is to be compressed using Huffman coding: AAAABBBCCD
(a)Explain what is meant by 'dictionary coding' as a method of lossless compression.(2)
(b)Complete a frequency table showing how many times each character (A, B, C, D) appears in the phrase AAAABBBCCD.(2)
(c)Explain why characters that occur more frequently, such as 'A', are given shorter binary codes in Huffman coding.(2)
(Total for Question 9 is 6 marks)
10
A programmer is writing a program, in the OCR Exam Reference Language, that helps photographers estimate storage needs. The program should input the width, height and colour depth (in bits) of a photo, calculate the file size in bytes, and output the result to the user.
Write pseudocode for this program.
(Total for Question 10 is 6 marks)
11
A small business owner is building a website to sell handmade jewellery. She needs to include high-quality product photographs and a short looping background music clip. Storage space and page loading speed are both important to her.
Discuss the compression choices the business owner should make for the images and the sound file on her website, and the impact of these choices on the customer's experience.
(Total for Question 11 is 6 marks)
12
A programmer has written the following algorithm, using the OCR Exam Reference Language, to decode run-length encoded data. Arrays are indexed from 0.
array runLengths[3]
array symbols[3]
runLengths[0] = 4
runLengths[1] = 2
runLengths[2] = 3
symbols[0] = "W"
symbols[1] = "B"
symbols[2] = "W"
output = ""

for i = 0 to 2
count = 0
while count < runLengths[i]
output = output + symbols[i]
count = count + 1
endwhile
next i
print(output)
i runLengths[i] symbols[i] output (after inner loop) 0 1 2
(a)Complete the trace table below to show the value of output after the inner WHILE loop finishes, for each pass of the outer FOR loop.(4)
(b)State the final value output by the program once the whole algorithm has finished running.(1)
(Total for Question 12 is 5 marks)
13
A file contains only the following characters, with these frequencies:
E: 8 T: 5 A: 3 O: 2
A Huffman tree is to be built to assign binary codes to each character, with the most frequent characters given the shortest codes.
(a)Describe the general method used to build a Huffman tree from a frequency table.(3)
(b)Using the frequencies given, calculate the total number of bits needed to store the whole file if a fixed-length binary code were used for every character instead of Huffman coding.(3)
(Total for Question 13 is 6 marks)
14
Using the same frequencies as the previous question (E: 8, T: 5, A: 3, O: 2), Huffman coding was used to generate the following variable-length codes:
E = 0 T = 10 A = 110 O = 111
(a)Calculate the total number of bits needed to store the whole file using these Huffman codes.(3)
(b)Calculate the number of bits saved by using Huffman coding compared to the fixed-length code from the previous question, and hence calculate the percentage saving in file size.(3)
(Total for Question 14 is 6 marks)
15
A video call application sends both image frames and sound at the same time.
Each video frame is 640 x 480 pixels with a colour depth of 16 bits per pixel. The application sends 2 frames every second.
The sound is sampled at 8000 Hz with a bit depth of 16 bits, recorded in stereo (2 channels).
(a)Calculate the number of bits needed to store one uncompressed video frame.(2)
(b)Calculate the total number of bits of video data sent in one second, given that 2 frames are sent per second.(1)
(c)Calculate the number of bits of sound data generated in one second.(2)
(d)Calculate the total combined number of bits per second (video and sound together) that the application must transmit, and hence explain why real-time video calls almost always use compression.(3)
(Total for Question 15 is 8 marks)
Mark scheme · 2.6 Data Representation: Images, Sound and Compression

Question 1

  • (a) the number of bits used to represent/store the colour of each pixel (oe)B1
  • (a) Answer: The number of bits used to represent the colour of each pixel.
  • (b) recognises number of colours = 2colour depth, i.e. 24 (oe)M1
  • (b) 16 caoA1
  • (b) Answer: 16 colours
  • (c) D caoB1
  • (c) Answer: D) 8 bits

Question 2

  • (a) recognises 2n must be at least 32, e.g. tests 24 = 16 (too small) and 25 = 32 (oe)M1
  • (a) 5 (bits) caoA1
  • (a) Answer: 5 bits
  • (b) correct place value working shown using place values 16, 8, 4, 2, 1 (oe)M1
  • (b) 10011 cao (ft from part a for number of bits)A1
  • (b) Answer: 10011
  • (c) converts binary to denary or splits into a nibble/group for conversion, e.g. 11010 = 26 (oe)M1
  • (c) 1A cao (accept 0x1A oe)A1
  • (c) Answer: 1A

Question 3

  • (a) 256 caoB1
  • (a) Answer: 256 colours
  • (b) calculates the total number of pixels: 320 x 240 = 76800 (oe)M1
  • (b) 76800 x 8 = 614400 shown correctly cso (answer given, working must be shown)A1
  • (b) Answer: 320 x 240 = 76800 pixels; 76800 x 8 = 614400 bits
  • (c) converts bits to bytes: 614400 / 8 (= 76800) (oe, ft from part b)M1
  • (c) 76.8 (KB) cao ftA1
  • (c) Answer: 76.8 KB

Question 4

  • (a) the number of samples of the sound wave taken per second, measured in Hertz (Hz) (oe)B1
  • (a) Answer: The number of samples of the sound wave taken per second.
  • (b) the number of bits used to store/represent each sample (oe)B1
  • (b) Answer: The number of bits used to store each sample.
  • (c) the recording more closely/accurately matches the original analogue sound wave, giving higher quality sound (oe)B1
  • (c) Answer: The recording more closely matches the original sound wave, giving higher quality.
  • (d) the file size increases, as more samples must be stored (oe)B1
  • (d) Answer: The file size increases because more samples must be stored.

Question 5

  • (a) correct method: 8000 x 3 (oe)M1
  • (a) 24000 (samples) caoA1
  • (a) Answer: 24000 samples
  • (b) multiplies number of samples by bit depth: (their samples) x 8 (oe, ft from part a)M1
  • (b) 192000 (bits) cao ftA1
  • (b) Answer: 192000 bits
  • (c) converts bits to bytes: (their bits) / 8 (= 24000) (oe, ft from part b)M1
  • (c) 24 (KB) cao ftA1
  • (c) Answer: 24 KB

Question 6

  • (a) stereo requires two channels of audio data to be stored instead of one (oe)B1
  • (a) so the file size (approximately) doubles compared to the equivalent mono recording (oe, ft)B1
  • (a) Answer: Stereo stores two channels of audio instead of one, so the file size roughly doubles compared to mono.
  • (b) a lower bit depth produces a smaller file size, so it downloads/streams faster and uses less of the listener's mobile data allowance (oe)B1
  • (b) spoken word/podcast audio does not need the same level of quality as music, so the small loss in quality is unlikely to be noticeable on a phone speaker (oe)B1
  • (b) Answer: A lower bit depth gives a smaller file that streams faster and uses less mobile data; speech does not need studio-quality sound, so the small quality loss is not very noticeable.

Question 7

  • (a) to compress data by storing a value and how many times it repeats (its run length), instead of storing the value once for every repeat (oe)B1
  • (a) Answer: It compresses data by storing a repeated value once along with a count of how many times it repeats.
  • (b) identifies the three correct runs, in order: 5 white, 3 black, 4 white (oe)M1
  • (b) 5W 3B 4W cao (accept equivalent consistent notation, e.g. (5,W)(3,B)(4,W))A1
  • (b) Answer: 5W 3B 4W
  • (c) images with large areas of a single/repeated colour, e.g. simple line drawings, icons or logos, compress well (oe)B1
  • (c) photographs, or images with lots of colour variation/noise between adjacent pixels, compress poorly, as there are few or no long runs (oe)B1
  • (c) Answer: RLE works well on simple images with large blocks of one colour (e.g. a logo), but poorly on photographs, which have little colour repetition between adjacent pixels.

Question 8

  • (a) correctly identifies the total number of pixels represented: 6 + 2 + 6 = 14 (oe)M1
  • (a) WWWWWW BB WWWWWW cao (14 symbols in the correct order)A1
  • (a) Answer: WWWWWWBBWWWWWW (14 pixels)
  • (b) correctly finds the original size: 14 pixels x 1 byte = 14 bytes (ft from part a)M1
  • (b) correctly finds the encoded size: 3 runs x 2 bytes = 6 bytes (oe)M1
  • (b) (7/3):1, approximately 2.33:1 cao (accept awrt 2.3:1)A1
  • (b) Answer: (7/3):1, approximately 2.33:1

Question 9

  • (a) frequently occurring data (e.g. repeated characters, strings or words) is replaced by a shorter code/index that refers to an entry in a dictionary/table (oe)B1
  • (a) the dictionary itself (matching each code to its full original value) is also stored, so the codes can be translated back to reconstruct the original data (oe)B1
  • (a) Answer: Repeated data is replaced with a shorter code that refers to an entry in a dictionary; the dictionary is stored too so the original data can be reconstructed from the codes.
  • (b) A = 4 and B = 3 both correctB1
  • (b) C = 2 and D = 1 both correctB1
  • (b) Answer: A = 4, B = 3, C = 2, D = 1
  • (c) assigning the shortest codes to the most frequently occurring characters (oe, ft from part b)B1
  • (c) reduces the total/average number of bits needed to store the whole file, because the most common symbol uses the fewest bits each time it appears (oe)B1
  • (c) Answer: Giving the most common character the shortest code means that symbol uses the fewest bits every time it appears, reducing the total number of bits needed for the whole file.

Question 10

  • correctly inputs the width using a sensibly named variable, e.g. width = int(input("Enter width: "))B1
  • correctly inputs the height using a sensibly named variableB1
  • correctly inputs the colour depth using a sensibly named variableB1
  • calculates the total number of pixels, e.g. totalPixels = width * heightB1
  • calculates total bits (totalPixels * colourDepth) and converts this to bytes by dividing by 8, e.g. totalBytes = totalBits / 8B1
  • outputs the calculated file size in bytes, e.g. print(totalBytes)B1
  • Answer:width = int(input("Enter width in pixels: "))
    height = int(input("Enter height in pixels: "))
    colourDepth = int(input("Enter colour depth in bits: "))

    totalPixels = width * height
    totalBits = totalPixels * colourDepth
    totalBytes = totalBits / 8
    print(totalBytes)

Question 11

  • Level 1 Basic, isolated point(s) made, e.g. that compression makes files smaller. Little or no reference to the impact on quality or loading speed. Limited use of technical terms.1-2
  • Level 2 Some relevant discussion of lossy or lossless compression with limited application to the images and/or the sound file. A link is made between file size and loading speed or quality, but this is not fully developed for both media types. Reasonable use of technical terms.3-4
  • Level 3 Sustained, well-structured discussion that applies compression concepts directly to both the images and the sound file, weighing up the trade-off between quality and loading speed/storage, and justifying suitable choices for the business owner. Accurate and consistent use of technical terminology throughout.5-6
  • Indicative content:
    • Product photos need to look attractive and detailed, so some quality is important; a high-quality lossy format (e.g. JPEG) is likely to give a good balance between quality and file size.
    • Fully lossless images would give the best possible quality but produce much larger files, which could slow down page loading and put customers off.
    • As long as the loss of quality from lossy compression is not very noticeable, using it on the product photos keeps file sizes down and pages loading quickly.
    • The background music clip is short, loops repeatedly and does not need studio-quality sound, so a lossy audio format (e.g. MP3) with a lower bit rate/sample rate would be suitable.
    • A smaller sound file also loads faster and uses less data, which particularly benefits customers browsing on mobile devices or slower connections.
    • Overall the business owner should balance an acceptable level of quality against fast loading times, since slow-loading pages may cause customers to leave the site before making a purchase.

Question 12

  • (a) i = 0: runLengths[0] = 4, symbols[0] = "W", output = "WWWW"B1
  • (a) i = 1: runLengths[1] = 2, symbols[1] = "B", output = "WWWWBB"B1
  • (a) i = 2: runLengths[2] = 3, symbols[2] = "W", output = "WWWWBBWWW"B1
  • (a) all three rows fully consistent (correct index, run length and symbol values used throughout)B1
  • (a) Answer: i=0: output="WWWW"; i=1: output="WWWWBB"; i=2: output="WWWWBBWWW"
  • (b) WWWWBBWWW cao ft (from part a)B1
  • (b) Answer: WWWWBBWWW

Question 13

  • (a) repeatedly combine/merge the two nodes (symbols, or previously combined nodes) with the lowest frequencies into a new node (oe)B1
  • (a) the new node's frequency is the sum of the two combined frequencies; this is repeated until only one node (the root) remains (oe)B1
  • (a) starting from the root, a 0 or 1 is assigned to each branch to build the binary code for each character; characters that are fewer branches from the root (more frequent) end up with shorter codes (oe)B1
  • (a) Answer: Repeatedly merge the two lowest-frequency nodes into a new node whose frequency is their sum, until one root node remains; then assign 0/1 to each branch from the root to generate each character's code, giving more frequent characters shorter codes.
  • (b) recognises that 4 different characters need 2 bits each for a fixed-length code, since 22 = 4 (oe)M1
  • (b) finds the total number of characters in the file: 8 + 5 + 3 + 2 = 18 (oe)M1
  • (b) 36 (bits) caoA1
  • (b) Answer: 36 bits

Question 14

  • (a) identifies the correct code length for each character: E = 1 bit, T = 2 bits, A = 3 bits, O = 3 bits (oe)M1
  • (a) multiplies each frequency by its code length and finds each product: 8x1=8, 5x2=10, 3x3=9, 2x3=6 (oe)M1
  • (a) 33 (bits) caoA1
  • (a) Answer: 33 bits
  • (b) finds the bits saved: 36 - 33 = 3 (bits) (oe, ft from previous question and part a)M1
  • (b) correct method for percentage: (3 / 36) x 100 (oe, ft)M1
  • (b) awrt 8.3% cao ftA1
  • (b) Answer: 3 bits saved; awrt 8.3% reduction in file size

Question 15

  • (a) correct method: 640 x 480 x 16 (oe)M1
  • (a) 4915200 (bits) caoA1
  • (a) Answer: 4 915 200 bits
  • (b) 9830400 (bits per second) cao ft (their part a x 2)B1
  • (b) Answer: 9 830 400 bits per second
  • (c) correct method: 8000 x 16 x 2 (oe)M1
  • (c) 256000 (bits) caoA1
  • (c) Answer: 256 000 bits per second
  • (d) adds video and sound data rates together: (their part b) + (their part c) (oe, ft)M1
  • (d) 10086400 (bits per second) cao ftA1
  • (d) explains that compression reduces the bandwidth required, helping avoid congestion and delays on connections with limited available bandwidth (oe)B1
  • (d) Answer: 10 086 400 bits per second; compression reduces the bandwidth required and helps avoid congestion and delays on connections with limited available bandwidth.

Mark your answers

Check answers without an account. Some answers can be checked automatically; use the mark scheme to mark the rest.

Question 1(a)

1 mark
Did your answer earn the marks?

Question 1(b)

2 marks

Question 1(c)

1 mark
Choose an answer

Question 2

6 marks
Did your answer earn the marks?

Question 3

5 marks
Did your answer earn the marks?

Question 4

4 marks
Did your answer earn the marks?

Question 5

6 marks
Did your answer earn the marks?

Question 6

4 marks
Did your answer earn the marks?

Question 7

5 marks
Did your answer earn the marks?

Question 8

5 marks
Did your answer earn the marks?

Question 9

6 marks
Did your answer earn the marks?

Question 10

6 marks
Did your answer earn the marks?

Question 11

6 marks
Did your answer earn the marks?

Question 12

5 marks
Did your answer earn the marks?

Question 13

6 marks
Did your answer earn the marks?

Question 14

6 marks
Did your answer earn the marks?

Question 15

8 marks
Did your answer earn the marks?
Mark my answers

Worksheets are written for Revision Library and come with a full mark scheme; a few English packs quote an out-of-copyright text, and name it on the page. Exam board names and specification codes say which qualification a pack suits: we are not affiliated with, endorsed by or approved by any exam board, and no past-paper question is reproduced here. Rights queries: hello@revisionlibrary.co.uk