Teach Computer Science
Free Sample
THANK YOU FOR DOWNLOADING THIS FREE SAMPLE RESOURCE!
Here, you’ll find a snippet of the module, which you can use to gauge the quality
of our offering, but will also find super useful in the classroom.
Teach Computer Science is an affordable, high-quality offering for teachers and
students alike whether that’s in the classroom, online, or homeschool
environment. You’ll find everything you need to learn or teach a computer
science subject for students aged 11-14, 14-16, and 16+ following any of the UK
examination boards, or any other curriculum from around the world.
If you want the complete module, which contains classroom presentation,
revision notes, quizzes, mind maps, flashcards, activities and answer keys, then
please upgrade to one of our Premium plans and support our quest to make
education affordable for all.
The Teach Computer Science Team
teachcomputerscience.com
Teach Computer Science
A-Level
Compression,
Encryption and
Hashing
teachcomputerscience.com
1.
Revision notes
teachcomputerscience.com
Introduction
File handling is one of the primary functions of a computer system.
Based on the type of data that needs to be stored, several types of file
formats are available. Each file format occupies a certain amount of
storage space.
An image file with good quality occupies around 1 MB, and a video file
needs to store 25 frames per second, occupying a large amount of
storage space. Thus, compression methods are used to reduce the size
of the files. Compression is also helpful in reducing the download time
of image, audio, and videos files from the Internet. In this chapter,
different types of files formats and compression methods are
explained.
Compressing Image files
Image compression is the reduction in file size to reduce download
times and storage requirements. Compressing an image also changes
its attributes, such as file type, resolution, dimensions and bit depth.
There are two types of compression:
a) Lossless compression:
When the file is compressed, the quality of the image remains the
same, and the image can be reconstructed into its original form. In this
case, information is very important and cannot be lost. Let us consider
a text file with the following sentence:
“See a pin and pick it up, all the day you'll have good luck; see a pin
and let it lie, bad luck you'll have all day”.
This text file can be compressed by making a table for this
information.
teachcomputerscience.com
Index word
1 see
2 a
3 pin
4 and
5 pick
6 it
7 up
8 all
9 the
10 day
11 you’ll
12 have
13 good
14 luck
15 let
16 lie
17 bad
The sentence can be coded in the form of numbers in the above table
and stored in the computer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 15 6 16 17 14 11 12 8 9 10
A character occupies a byte of memory. Whereas numbers occupy
comparatively less memory. The number 16 is represented in 5 bits
(10000). This saves memory by using codes for words that are
repeated. This is a type of lossless compression. With the code and the
index table, the complete sentence can be recreated. This type of
coding is also called dictionary coding.
teachcomputerscience.com
2.
Activities
teachcomputerscience.com
Activity-1
Duration: 15 minutes
1. Use Huffman coding to create a Huffman tree for the sentence:
GOOD MORNING GORDON. Also, state the character coding for
each character.
Letter
Frequency
Binary
value
1. Using Huffman coding, how many bits have you saved?
teachcomputerscience.com
Activity-1
Duration: 15 minutes
1.Use Huffman coding to create a Huffman tree for the sentence: GOOD
MORNING GORDON. Also, state the character coding for each character.
0 1
0 G 1 0 O
1
D N
0 1 0 1
I M R Sp
.
Letter G D I M N O R Space
Frequency 2 3 1 1 3 5 2 2
Binary 0 00 010 011 10 1 110 111
value
1.Using Huffman coding, how many bits have you saved?
Without coding: 19 × 7 = 133 bits
With Huffman coding: (2+6+3+3+6+5+6+6)=37 bits
Number of bits saved: 133-37=96 bits
teachcomputerscience.com
Flashcards
What is To reduce the size of the files
and reduce the download
compression used time of an image, audio and
for? video from the Internet.
What are the two
Lossless compression and
types of lossy compression.
compression?
teachcomputerscience.com
Glossary
A data structure made of nodes and
Binary tree
constructed based on hierarchy.
Number of bits used to represent each clip in
Bit depth
an audio file.
Bitrate Number of bits used per second of audio.
Programs that encode audio, image or video
Codec
files.
Compression A method to reduce the file size of a file.
An electronic document that confirms the
Digital certificates
ownership of public keys.
teachcomputerscience.com
Quiz
1. Which of the following is true about lossless compression
technique?
A. The file cannot be reconstructed back to its original form.
B. The quality of the file remains the same after compression.
C. The memory required to store the file after compression
remains the same.
D. All of the above.
2. Which of the following is true about lossy compression
technique?
A. The quality of the file remains the same after compression.
B. The memory required to store the file after compression
remains the same.
C. The unnecessary bits of information are removed
permanently.
D. All of the above.
3. What is the function of compression?
A. Reducing the file size.
B. Increasing the file quality.
C. Converting analogue signals to digital files.
D. All of the above.
teachcomputerscience.com
Teach Computer Science
This resource is licensed under the Creative Commons Attribution-
NonCommercial 4.0 International license.
You are free to:
● Share — copy and redistribute the material in any medium or
format
● Adapt — remix, transform, and build upon the material
Under the following terms:
● Attribution — You must give appropriate credit, provide a link to
the license, and indicate if changes were made. You may do so
in any reasonable manner, but not in any way that suggests the
licensor endorses you or your use.
● NonCommercial — You may not use the material for
commercial purposes.
For more information on this license, visit the following link:
http://creativecommons.org/licenses/by-nc/4.0/
Thank you!
teachcomputerscience.com
Teach Computer Science
Thank you so much for downloading this resource!
We hope it has been useful for you in the classroom and that your
students enjoy the activities.
For more teaching resources like this, don’t forget to come back
and download the new material we add every week!
Thanks for supporting Teach Computer Science. We can provide
teachers with low-cost, high-quality teaching resources because
of our loyal subscribers and hope to serve you for many years to
come.
- The Teach Computer Science Team :)
teachcomputerscience.com