Grade 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 recognize the rows where it costs more than it saves.
Name: ________________________
1.A picture is 20 pixels wide and 15 pixels tall. Every row of it is a single color the whole way across, and a run is never allowed to carry on from one row into the next. How many runs does the whole picture have?
2.A counted row reads “4W2B5W”. How many pixels long is the row it stands for?
3.Another row reads “WWWWWBBRRRR”. Write this one in counted form.
4.A row of 90 pixels has 12 runs. Written out pixel by pixel it costs one thing per pixel; written as runs it costs two things per run. How many things does writing it as runs save?
5.A row of pixels reads “RRRRRRRGGG”. Write it in counted form, using a number and then the letter for each run.
6.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) Neither: counting runs saves the same amount on any picture
- c) The sky, because long stretches of it are the same color
- d) The crowd, because there are more colors in it altogether
7.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?
8.Put these rows of pixels in order of how many runs each one has, fewest first.
- RGBRGBR
- RRWWBBGG
- GGGGGGGG
- RRRRWWWW
Answer key — Grade 9 Computer Science — Making a file smaller
- 1. 15
- 2. 11
- 3.
- 5W2B4R
- 5W 2B 4R
- 4. 66
- 5.
- 7R3G
- 7R 3G
- 6. c) The sky, because long stretches of it are the same color
- 7. 6
- 8. 1. GGGGGGGG 2. RRRRWWWW 3. RRWWBBGG 4. RGBRGBR