{"base":{"id":"cs8-16","subject":"Systems","title":"Making files smaller","scene":"chip","steps":[{"mode":"filesize","eyebrow":"File size","title":"Why size matters","body":"Big files fill storage and take longer to send. Time to send = file size ÷ connection speed. Change the speed and compare a message, a photo, a song and a film clip.","controls":[{"id":"speed","label":"Connection speed","min":5,"max":100,"step":5,"value":20,"unit":"Mbit/s"}]},{"mode":"rle","eyebrow":"Run-length encoding","title":"Count the repeats","body":"Compression stores the same information with fewer bits. Run-length encoding stores each run of one colour as a count and a colour: 3W means 3 white pixels. Encode the picture.","actions":[{"id":"row","label":"Encode the next row"},{"id":"all","label":"Encode all rows"}]},{"mode":"noisy","eyebrow":"When it fails","title":"Not every picture shrinks","body":"Run-length encoding only helps when there are long runs. A busy picture has short runs. Compare the two pictures and the number of values each needs.","actions":[{"id":"simple","label":"Simple picture"},{"id":"noisy","label":"Busy picture"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Encode a row","body":"A row of pixels is: white, white, white, black, black, white, white, white.","question":"What is its run-length code?","options":["8W","1W 1B 1W","3W 2B 3W"],"answer":2,"right":"Correct. Three whites, two blacks, three whites.","wrong":"Not quite. Count each run of the same colour.","look":"rle"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"Compression always makes files smaller.\"","body":"Not always. Run-length encoding can make a busy picture bigger."},{"tag":"Popular idea","title":"\"A compressed file is always lower quality.\"","body":"Lossless compression, like run-length encoding, rebuilds the file exactly. Only lossy compression throws detail away."},{"tag":"Popular idea","title":"\"Zipping a photo makes it much smaller.\"","body":"JPEG photos are already compressed, so zipping them saves very little."}]},{"type":"cards","id":"types","eyebrow":"Two kinds","title":"Lossless and lossy","items":[{"tag":"Lossless","title":"Nothing lost","body":"The original can be rebuilt exactly. Used for text, programs and simple graphics (ZIP, PNG, run-length encoding)."},{"tag":"Lossy","title":"Detail thrown away","body":"Removes detail people hardly notice, for much smaller files. Used for photos, music and streaming video (JPEG, MP3)."}]},{"type":"cards","id":"worked","eyebrow":"Worked example","title":"Encoding a row","items":[{"tag":"Row","title":"8 pixels","body":"W W B B B B W W\n→ 2W 4B 2W\n8 values → 6 values","code":true},{"tag":"Busy row","title":"8 pixels","body":"W B W B W B W B\n→ 1W 1B 1W 1B 1W 1B 1W 1B\n8 values → 16 values!","code":true}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Pixel art","items":[{"title":"Compress a picture","time":"20 minutes","need":["Squared paper","A pencil"],"steps":["Colour a simple 8 × 8 picture in black and white, such as a heart or a smiley.","Write the run-length code for each row, e.g. 2W 4B 2W.","Count the values in your code and compare with 64.","Give only the code to a friend. Can they rebuild your picture exactly?"],"why":"If your friend's copy matches, the compression was lossless. Big blocks of one colour compress best.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"Why are smaller files useful?","options":["They send faster and take less storage","They look brighter","They never get viruses"],"answer":0,"right":"Correct. Less data to move and store.","wrong":"Not quite. Think about sending and storing."},{"question":"What does 4B mean in run-length encoding?","options":["4 black pixels in a row","4 bytes","Black at position 4"],"answer":0,"right":"Correct. A count and a colour.","wrong":"Not quite. Count, then colour."},{"question":"Which picture compresses best with RLE?","options":["A photo of leaves","Random dots","A flag with big blocks of colour"],"answer":2,"right":"Correct. Long runs of one colour.","wrong":"Not quite. Which has long runs?"},{"question":"What does lossless mean?","options":["Some detail is thrown away","The file can be rebuilt exactly","It can't be opened"],"answer":1,"right":"Correct. No information is lost.","wrong":"Not quite. Less loss… none at all."},{"question":"A 400-megabit file is sent at 20 Mbit/s. How long does it take?","options":["8 s","20 s","80 s"],"answer":1,"right":"Correct. 400 ÷ 20 = 20 seconds.","wrong":"Not quite. Divide size by speed."},{"question":"Which type of compression do music streaming services mostly use?","options":["Lossless only","Lossy","None"],"answer":1,"right":"Correct. Lossy gives much smaller files for streaming.","wrong":"Not quite. Which kind makes files much smaller?"}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["why smaller files save storage and time","the difference between lossless and lossy compression","how to write the run-length code for a row of pixels","why run-length encoding doesn't suit busy pictures"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"file size","meaning":"How much storage a file takes, in bytes."},{"word":"compression","meaning":"Storing the same information using fewer bits."},{"word":"lossless","meaning":"Compression where the original can be rebuilt exactly."},{"word":"lossy","meaning":"Compression that throws away some detail."},{"word":"run-length encoding","meaning":"Storing each run of repeated values as a count and a value."},{"word":"pixel","meaning":"One tiny dot of colour in a picture."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize GCSE Computer Science: Compression"]}]},"overlay":null}