0% found this document useful (0 votes)
42 views22 pages

L4 Algorithmic Thinking 2

The document discusses compression algorithms and their use in reducing data size for transmission and storage. It aims to help understand the difference between lossy and lossless compression, how to improve compression algorithms using a binary tree, and why compression is needed for video and photos. Examples are given of compressing a quote and representing letters in a binary tree to communicate efficiently.

Uploaded by

danmc1984
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views22 pages

L4 Algorithmic Thinking 2

The document discusses compression algorithms and their use in reducing data size for transmission and storage. It aims to help understand the difference between lossy and lossless compression, how to improve compression algorithms using a binary tree, and why compression is needed for video and photos. Examples are given of compressing a quote and representing letters in a binary tree to communicate efficiently.

Uploaded by

danmc1984
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Objectives

• Understand the difference between lossy and


lossless compression
• Be able to use an algorithm to communicate data
• Understand how the algorithm can be improved
• Use a binary tree to further improve the algorithm

• Understand why compression is needed for video


transmission and photo storage
Algorithmic thinking 2
Computational thinking and logic

Starter
• How could you reduce the number of letters used
in the following quote, but still understand it?
“That’s one small step for a man, one
giant leap for mankind”

Neil Armstrong

Target: Aim to reduce


the number of letters
and spaces (characters)
to less than 50
Algorithmic thinking 2
Computational thinking and logic

Starter
• “That’s one small step for a man, one giant leap
for mankind”
• Some possible answers:
• That’s 1 small step for 1 man, 1 giant leap for mankind (55
chars)
• Thts 1 smll step fr 1 man, 1 giant leap fr manknd (49 chars)
• Thts 1 smll fr 1 , 1 giant leap fr knd (41 chars)
Algorithmic thinking 2
Computational thinking and logic

Compression
• Compression means reducing the amount of data
needed to store or transmit something
• Lossy compression means that some of the original data
will be lost
• Lossless compression means that none of the original data
will be lost
• Is the method you just used to compress the data
lossy or lossless?
• Describe an algorithm that could be used to compress
quotes in the way you have in the starter
Algorithmic thinking 2
Computational thinking and logic

Compression
• Is the method you just used to compress the data
lossy or lossless?
• Lossy compression

• Describe an algorithm that could be used to


compress quotes in the way you have in the starter
• IF the word can have a picture to represent it THEN replace

with an emoji
• IF the word has vowels in it, AND is a common word, THEN
remove the vowels
• IF the word is a number THEN replace with digits
• IF comma or apostrophe THEN remove
Algorithmic thinking 2
Computational thinking and logic

Worksheet 4
• Complete Task 1 on Worksheet 4
Algorithmic thinking 2
Computational thinking and logic

Locked-in syndrome
• Locked-in syndrome causes people to become
completely paralysed except for control of the eyes
• People with locked-in syndrome are fully conscious and
aware, so use blinking or eye movements to communicate
• If they are shown a table of the alphabet, they can blink
when
someone points to the correct letter
• Think of a word and try to communicate it with a partner
using the table on the following slide
Algorithmic thinking 2
Computational thinking and logic

Communication by blinking
• Partner 1: Think of a word. Don’t tell your partner
• Partner 2: Point to each of the letters on the alphabet in
turn
• Partner 1: If your partner says the next letter from your
word
then blink
• Partner 2: How many letters did you ask before you worked
out the word? A B C D E F G H I J
K L M N O P Q R S T
U V W X Y Z
Algorithmic thinking 2
Computational thinking and logic

Letter order
• Using the letter order of the
alphabet makes the algorithm 14

for finding each letter inefficient 12

• Look at the chart below which 10

shows how often each letter is

Frequency %
8
used in typical English
6

• What is the most common letter? 4

• If we redesigned the chart, what 2

should the first four letters be? 0


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Algorithmic thinking 2
Computational thinking and logic

Letter order
• What is the most common letter? E
• If we redesigned the chart, what should the first four
letters be? E, T, A, O
• The full chart would be:

E T A O I N S H R D
L C U M W F G Y P B
V K X J Q Z
Algorithmic thinking 2
Computational thinking and logic

Worksheet 4
• Complete Task 2 on Worksheet 4
Algorithmic thinking 2
Computational thinking and logic

Another algorithm
• Let’s arrange the letters into a binary tree
• This time we use a LEFT or RIGHT
wink to indicate the direction on the tree

• What letters would the following winks give?


RIGHT
LEFT
RIGHT, RIGHT
Algorithmic thinking 2
Computational thinking and logic

What does this say?


• Work out what the following says:
RIGHT LEFT LEFT RIGHT LEFT LEFT RIGHT
LEFT RIGHT RIGHT LEFT
LEFT LEFT LEFT LEFT RIGHT
RIGHT RIGHT LEFT
LEFT RIGHT RIGHT LEFT LEFT
LEFT RIGHT LEFT LEFT LEFT
RIGHT LEFT RIGHT RIGHT RIGHT
RIGHT LEFT LEFT

LEFT
Algorithmic thinking 2
Computational thinking and logic

Worksheet 4
• Complete Task 3 on Worksheet 4
• The answer to the previous slide is:
NOW DO NEXT TASK
Algorithmic thinking 2
Computational thinking and logic

Storing text with ASCII


• To store text on a computer, each character (letter,
number or punctuation symbol) requires 8 bits
• A bit is a 0 or 1
• How many bits are required to store “HAPPY BIRTHDAY”?
• Using 0 for LEFT and 1 for RIGHT, how many bits are
required to store “HAPPY BIRTHDAY” when using the
binary tree?
Algorithmic thinking 2
Computational thinking and logic

Storing text with ASCII


• How many bits are required to store “HAPPY BIRTHDAY”?
14 characters * 8 = 112 bits (remember the space)
• Using 0 for LEFT and 1 for RIGHT, how many bits are
required to store “HAPPY BIRTHDAY” when using the
binary tree?
(H) 0 0 1
(A) 0 0
(I) 11
(R) 010
(D) 011
(A) 00 = 41 bits
(41 binary digits on the left are
(P) 0 1 0 0 (T) 10 (Y) 0011
(P) 0 1 0 0 (H) 001 needed to find all the letters)
(Y) 0 0 1 1
(_) 1
(B) 0101
Algorithmic thinking 2
Computational thinking and logic

Why use compression?


• Uncompressed HD TV needs about 3,000
megabits for one second of video
• Compressed video requires just 25 megabits for one
second
• So we wouldn’t have streaming
TV without compression
• A smartphone photo needs
about 47 megabytes to
store uncompressed
• But just a few megabytes
to store when compressed
Algorithmic thinking 2
Computational thinking and logic

Worksheet 4
• Complete Task 4 on Worksheet 4
Algorithmic thinking 2
Computational thinking and logic

Plenary
• Answer the following questions in a pair
• When data is compressed, if the compressed version restores
to exactly the same data is it lossy or lossless compression?
• Use the binary tree at the bottom of the slide to work out the
word represented by the following data:
00 10
1 0
1 11
01
01
0 0 1

0 1
1 0

0
Algorithmic thinking 2
Computational thinking and logic

Plenary
• When data is compressed, if the compressed version
restores to exactly the same data is it lossy or lossless
compression?
Lossless compression
• Use the binary tree at the bottom of the slide to work out the
word represented by the following data:
00 B 10 P BOOKKEEPER
1 O 0 E
1 O 11 R
01 K
01 K
0 E 0 1

0 1
1 0

0 E
Algorithmic thinking 2
Computational thinking and logic

Copyright

© 2023 PG Online Limited

The contents of this unit are protected by copyright.

This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by
you only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part
of the materials distributed with this unit may be used, reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic or otherwise, without the prior written permission of
PG Online Limited.

Licence agreement

This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the
worksheets, PowerPoint presentations, teaching guides and other associated files distributed with it is
licensed, not sold, to you by PG Online Limited for use under the terms of the licence.

The materials distributed with this unit may be freely copied and used by members of a single institution on
a single site only. You are not permitted to share in any way any of the materials or part of the materials
with any third party, including users on another site or individuals who are members of a separate
institution. You acknowledge that the materials must remain with you, the licencing institution, and no part
of the materials may be transferred to another institution. You also agree not to procure, authorise,
encourage, facilitate or enable any third party to reproduce these materials in whole or in part without the
prior permission of PG Online Limited.

You might also like