Class 9 Computer Science — Making a file smaller
Squeeze a run of repeated values into a count and a value, work out what that saves, and recognise the rows where it costs more than it saves.
Name: ________________________
1.Writing a row out pixel by pixel costs one thing per pixel; writing it as runs costs two things per run. Sort each row by which of the two costs less.
Groups: Runs cost fewer things · Runs cost more things
- 24 pixels, 3 runs
- 18 pixels, 11 runs
- 60 pixels, 4 runs
- 50 pixels, 9 runs
- 16 pixels, 10 runs
- 30 pixels, 20 runs
2.A row of 96 pixels has 8 runs, and writing it as runs costs two things per run. How many times smaller than the pixel-by-pixel form is the counted form?
3.Match each row of pixels to the number of runs it has.
- BBBWWBB
- RRRRRRRR
- RGRGRG
- WWWWBB
- RRGGBBRRG
- 3
- 6
- 1
- 2
- 5
4.A row of 20 pixels changes colour at every single pixel along it. Writing it as runs costs two things per run. What does counting the runs do to the size of this row?
- a) It doubles it, from 20 things to 40
- b) It brings it down to 2 things
- c) It leaves it at exactly 20 things
- d) It halves it, from 20 things to 10
5.Two photographs have exactly the same number of pixels. One is of a clear sky and the other is of a crowd of people. Counting runs makes one of them much smaller than the other. Which one, and why?
- a) The sky, because it has fewer pixels in it
- b) The crowd, because there are more colours in it altogether
- c) The sky, because long stretches of it are the same colour
- d) Neither: counting runs saves the same amount on any picture
6.A row of 40 pixels has 5 runs in it. Writing the row as runs costs two things for every run — a count and a letter. How many things does that come to?
7.Another row reads “WWWWWBBRRRR”. Write this one in counted form.
8.A row of pixels reads “RRRRRRRGGG”. Write it in counted form, using a number and then the letter for each run.
Answer key — Class 9 Computer Science — Making a file smaller
- 1. 60 pixels, 4 runs → Runs cost fewer things; 30 pixels, 20 runs → Runs cost more things; 50 pixels, 9 runs → Runs cost fewer things; 16 pixels, 10 runs → Runs cost more things; 24 pixels, 3 runs → Runs cost fewer things; 18 pixels, 11 runs → Runs cost more things
- 2. 6
- 3. BBBWWBB → 3; RRRRRRRR → 1; RGRGRG → 6; WWWWBB → 2; RRGGBBRRG → 5
- 4. a) It doubles it, from 20 things to 40
- 5. c) The sky, because long stretches of it are the same colour
- 6. 10
- 7.
- 5W2B4R
- 5W 2B 4R
- 8.
- 7R3G
- 7R 3G