87
Teaching the Principles of Computing to Primary-Aged Kids Professor Barry O’Sullivan and Kate O’Sullivan (Age 9)

Teaching the Principles of Computer Science to Primary-Aged Children

Embed Size (px)

DESCRIPTION

UCC Science, Engineering & Food Science Public Lecture - Professor Barry O'Sullivan Computers are extremely important in modern life. Understanding how they work, how they reason, how they "think", what are their limitations, is a fascinating subject called computer science.This lecture is focused on making the fundamental ideas of computer science accessible to children from the ages of 7-12 and their families. We present a set of learning activities that teach computer science through engaging games and puzzles that use cards, string, crayons and lots of running around. This lecture presents a subset of activities that form part of a Public Engagement Programme for Dublin City of Science 2012. Professor Barry O'Sullivan is Head of Department for Computer Science at University College Cork, Ireland. He is also Director of the Cork Constraint Computation Centre in the Computer Science Department at UCC, SFI Principal Investigator, Past President of the Association for Constraint Programming, Chairman of the Artificial Intelligence Association of Ireland, Coordinator of the EuropeanResearch Consortium for Informatics and Mathematics Working Group on Constraints, and Executive Council member of the Analytics Society of Ireland.

Citation preview

Page 1: Teaching the Principles of Computer Science to Primary-Aged Children

Teaching the Principles of Computing to Primary-Aged Kids

Professor Barry O’Sullivanand Kate O’Sullivan (Age 9)

Page 2: Teaching the Principles of Computer Science to Primary-Aged Children

My Assistant

Kate will help me with demonstrations.

Page 3: Teaching the Principles of Computer Science to Primary-Aged Children

Preview of a Public Engagement Event at the ESOF 2012, Dublinhttp://esof2012.org/

Page 4: Teaching the Principles of Computer Science to Primary-Aged Children

Credits: Computer Science Unplugged Resources

Page 5: Teaching the Principles of Computer Science to Primary-Aged Children

Computer science is about how we can solve problems with computersMulti-disciplinary, rich, deep, and rewarding area of study

Page 6: Teaching the Principles of Computer Science to Primary-Aged Children

What will we be talking about tonight?

• Computer science is important - economically and intellectually

• From Binary Numbers to Images and Codes

• What’s wrong with my brain? (Human Computer Interaction, Stroop Effect)

• Running Together (Sorting, Data Structures, and Parallel Computing)

• Coloring In (Graph Coloring, Combinatorics and Complexity Theory)

• Card Trick (Error Detection and Correction)

• Scratch (Computer Programming for Children)

Page 7: Teaching the Principles of Computer Science to Primary-Aged Children

Computer science is importantEconomically and intellectually

Page 8: Teaching the Principles of Computer Science to Primary-Aged Children

Consistently considered the best job in the USAhttp://money.cnn.com

Page 9: Teaching the Principles of Computer Science to Primary-Aged Children

Best Jobs in the World, 2011http://www.careercast.com

Page 10: Teaching the Principles of Computer Science to Primary-Aged Children
Page 11: Teaching the Principles of Computer Science to Primary-Aged Children
Page 12: Teaching the Principles of Computer Science to Primary-Aged Children
Page 13: Teaching the Principles of Computer Science to Primary-Aged Children
Page 14: Teaching the Principles of Computer Science to Primary-Aged Children
Page 15: Teaching the Principles of Computer Science to Primary-Aged Children
Page 16: Teaching the Principles of Computer Science to Primary-Aged Children
Page 17: Teaching the Principles of Computer Science to Primary-Aged Children
Page 18: Teaching the Principles of Computer Science to Primary-Aged Children
Page 19: Teaching the Principles of Computer Science to Primary-Aged Children
Page 20: Teaching the Principles of Computer Science to Primary-Aged Children
Page 21: Teaching the Principles of Computer Science to Primary-Aged Children
Page 22: Teaching the Principles of Computer Science to Primary-Aged Children
Page 23: Teaching the Principles of Computer Science to Primary-Aged Children
Page 24: Teaching the Principles of Computer Science to Primary-Aged Children
Page 25: Teaching the Principles of Computer Science to Primary-Aged Children
Page 26: Teaching the Principles of Computer Science to Primary-Aged Children

Skills Required by New IDA Investments in 2011

Other8%Sales

12%

Manuf.14%

Business19%

ICT47%

ICT Business Manuf. Sales Other

13,000 jobs in 2011148 investments No recession in software!

Page 27: Teaching the Principles of Computer Science to Primary-Aged Children

Let’s get started with some magic!

Page 28: Teaching the Principles of Computer Science to Primary-Aged Children

Photocopiable for classroom use only. 5

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,12#.)3456'#%)

7'2#1,18)&"9)(")+"41()So, you thought you knew how to count? Well, here is a new way to do it!

Did you know that computers use only zero and one? Everything that you see or hear on the computer—words, pictures, numbers, movies and even sound is stored using just those two numbers! These activities will teach you how to send secret messages to your friends using exactly the same method as a computer.

:1%(#4+(,"1%)Cut out the cards on your sheet and lay them out with the 16-dot card on the left as shown here:

Make sure the cards are placed in exactly the same order.

Now flip the cards so exactly 5 dots show—keep your cards in the same order!

Find out how to get 3, 12, 19. Is there more than one way to get any number? What is the biggest number you can make? What is the smallest? Is there any number you can’t make between the smallest and biggest numbers?

Extra for Experts: Try making the numbers 1, 2, 3, 4 in order. Can you work out a

logical and reliable method of flipping the cards to increase any number by one? Representing DataBinary Numbers

Page 29: Teaching the Principles of Computer Science to Primary-Aged Children

• Computers use the binary system to represent numbers.

• What is binary? A two-valued number system - only numbers being 0 and 1

• In school you might have known it as ‘base 2’. We use ‘base 10’ everyday.

• Each 0 or 1 is a bit, and computers use transistors to represent them.

• How do we get large numbers? Using many bits.

• Eight bits is a byte.

Binary Numbers - What’s this about?

Page 30: Teaching the Principles of Computer Science to Primary-Aged Children

Understanding Binary

4 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Binary Numbers

Introduction

Before giving out the worksheet on page 5, it can be helpful to demonstrate the principles

to the whole group.

For this activity, you will need a set of five cards, as shown below, with dots on one side

and nothing on the other. Choose five children to hold the demonstration cards at the

front of the class. The cards should be in the following order:

Discussion

What do you notice about the number of dots on the cards? (Each card has twice as many

as the card to its right.)

How many dots would the next card have if we carried on to the left? (32) The next…?

We can use these cards to make numbers by turning some of them face down and adding

up the dots that are showing. Ask the children to make 6 (4-dot and 2-dot cards), then 15

(8-, 4-, 2- and 1-dot cards), then 21 (16, 4 and 1)…

Now try counting from zero onwards.

The rest of the class needs to look closely at how the cards change to see if they can see a

pattern in how the cards flip (each card flips half as often as the one to its right). You may

like to try this with more than one group.

When a binary number card is not showing, it is represented by a zero. When it is

showing, it is represented by a one. This is the binary number system.

Ask the children to make 01001. What number is this in decimal? (9) What would 17 be

in binary? (10001)

Try a few more until they understand the concept.

There are five optional follow-up extension activities, to be used for reinforcement. The

children should do as many of them as they can.

Page 31: Teaching the Principles of Computer Science to Primary-Aged Children

Numbers in Binary

4 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Binary Numbers

Introduction

Before giving out the worksheet on page 5, it can be helpful to demonstrate the principles

to the whole group.

For this activity, you will need a set of five cards, as shown below, with dots on one side

and nothing on the other. Choose five children to hold the demonstration cards at the

front of the class. The cards should be in the following order:

Discussion

What do you notice about the number of dots on the cards? (Each card has twice as many

as the card to its right.)

How many dots would the next card have if we carried on to the left? (32) The next…?

We can use these cards to make numbers by turning some of them face down and adding

up the dots that are showing. Ask the children to make 6 (4-dot and 2-dot cards), then 15

(8-, 4-, 2- and 1-dot cards), then 21 (16, 4 and 1)…

Now try counting from zero onwards.

The rest of the class needs to look closely at how the cards change to see if they can see a

pattern in how the cards flip (each card flips half as often as the one to its right). You may

like to try this with more than one group.

When a binary number card is not showing, it is represented by a zero. When it is

showing, it is represented by a one. This is the binary number system.

Ask the children to make 01001. What number is this in decimal? (9) What would 17 be

in binary? (10001)

Try a few more until they understand the concept.

There are five optional follow-up extension activities, to be used for reinforcement. The

children should do as many of them as they can.

Page 32: Teaching the Principles of Computer Science to Primary-Aged Children

Some Fun with Binary

• How to we make:

• 3

• 12

• 19

• What do these numbers mean?

• 10101

• 01010

Page 33: Teaching the Principles of Computer Science to Primary-Aged Children

Binary can encode words and messages!

Page 34: Teaching the Principles of Computer Science to Primary-Aged Children

8 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0'12,13)0'+#'()4'%%53'%)

Tom is trapped on the top floor of a department store. It’s just before Christmas and he wants to get home with his presents. What can he do? He has tried calling, even yelling, but there is no one around. Across the street he can see some computer person still working away late into the night. How could he attract her attention? Tom looks around to see what he could use. Then he has a brilliant idea—he can use the Christmas tree lights to send her a message! He finds all the lights and plugs them in so he can turn them on and off. He uses a simple binary code, which he knows the woman across the street is sure to understand. Can you work it out?

6) 7) 8) 9) :) ;) <) =) >) 6?) 66) 67) 68)

5) @) +) 2) ') A) 3) &) ,) B) $) C) D)69) 6:) 6;) 6<) 6=) 6>) 7?) 76) 77) 78) 79) 7:) 7;)

1) ") E) F) #) %) () G) -) H) I) .) J)

Kate will help us decode a message encoded in binary

Page 35: Teaching the Principles of Computer Science to Primary-Aged Children

Binary enables communications

Photocopiable for classroom use only. 9

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0123,4)356)7"6'2%)

Computers connected to the internet through a modem also use the binary system to send messages. The only difference is that they use beeps. A high-pitched beep is used for a one and a low-pitched beep is used for a zero. These tones go very fast—so fast, in fact, that all we can hear is a horrible continuous screeching sound. If you have never heard it, listen to a modem connecting to the Internet, or try calling a fax machine—fax machines also use modems to send information.

Using the same code that Tom used in the department store, try sending an e-mail message to your friend. Make it easy for yourself and your friend though—you don’t have to be as fast as a real modem!

Page 36: Teaching the Principles of Computer Science to Primary-Aged Children

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

Representing Images on a ComputerData Compression - Run-Length Encoding

Page 37: Teaching the Principles of Computer Science to Primary-Aged Children

• Each computer screen is a grid of dots, called pixels

• The simplest screens have only black and white pixels

• By turning on/off the dots we can make pictures, text, etc.

• Grayscale screens have pixels that have a shade between black and white

• Color screens have pixels that have millions of different colors

• Images can be represented as numbers, and there are lots of different ways of doing that

How are images represented?

Page 38: Teaching the Principles of Computer Science to Primary-Aged Children

A simple image of the letter ‘a’

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

Page 39: Teaching the Principles of Computer Science to Primary-Aged Children

A simple image of the letter ‘a’

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

This is a data compression technique called Run-Length Encoding!

Page 40: Teaching the Principles of Computer Science to Primary-Aged Children

Photocopiable for classroom use only. 17

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,1)234)

The first picture is the easiest and the last one is the most complex. It is easy to make mistakes and therefore a good idea to use a pencil to colour with and have a rubber handy!

!"#$$#

!"#%"#&"#$#

!"#%"#&"#$#

!"#$$#

!"#%#

!"#%#

'"#(#

)"#$(#

$"#$'#

*"#'"#&"#+#

!"#&"#'"#&"#+"#$#

+"#$"#%"#$"#&"#$#

+"#$"#%"#$"#$"#$#

&"#$"#$$"#$#

&"#$"#$)"#&#

&"#$"#%"#$"#$"#$#

&"#$"#,"#$"#&"#$#

&"#$"#("#$"#+"#$#

$"#$"#$"#$"#!"#&"#+"#$#

)"#$"#&"#$"#&"#&"#'"#$#

)"#$"#+"#&"#'"#&#

$"#+"#&"#'#

*"#&"#&"#&#

'"#$"#&"#&"#&"#$#

*"#*#

!"#&"#*"#&#

+"#$"#$)"#$#

&"#$"#$&"#$#

&"#$"#+"#$"#!"#$"#+"#$#

$"#&"#$&"#&#

)"#$"#$*"#$#

)"#$"#*"#$"#&"#$"#*"#$#

)"#$"#("#&"#("#$#

$"#$"#$!"#$#

&"#$"#$&"#$#

&"#$"#'"#&"#'"#$#

+"#$"#$)"#$#

!"#&"#*"#&#

*"#*#

Kate will help us with some images....

Page 41: Teaching the Principles of Computer Science to Primary-Aged Children

Photocopiable for classroom use only. 17

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,1)234)

The first picture is the easiest and the last one is the most complex. It is easy to make mistakes and therefore a good idea to use a pencil to colour with and have a rubber handy!

!"#$$#

!"#%"#&"#$#

!"#%"#&"#$#

!"#$$#

!"#%#

!"#%#

'"#(#

)"#$(#

$"#$'#

*"#'"#&"#+#

!"#&"#'"#&"#+"#$#

+"#$"#%"#$"#&"#$#

+"#$"#%"#$"#$"#$#

&"#$"#$$"#$#

&"#$"#$)"#&#

&"#$"#%"#$"#$"#$#

&"#$"#,"#$"#&"#$#

&"#$"#("#$"#+"#$#

$"#$"#$"#$"#!"#&"#+"#$#

)"#$"#&"#$"#&"#&"#'"#$#

)"#$"#+"#&"#'"#&#

$"#+"#&"#'#

*"#&"#&"#&#

'"#$"#&"#&"#&"#$#

*"#*#

!"#&"#*"#&#

+"#$"#$)"#$#

&"#$"#$&"#$#

&"#$"#+"#$"#!"#$"#+"#$#

$"#&"#$&"#&#

)"#$"#$*"#$#

)"#$"#*"#$"#&"#$"#*"#$#

)"#$"#("#&"#("#$#

$"#$"#$!"#$#

&"#$"#$&"#$#

&"#$"#'"#&"#'"#$#

+"#$"#$)"#$#

!"#&"#*"#&#

*"#*#

...and an even bigger one.

Page 42: Teaching the Principles of Computer Science to Primary-Aged Children

What’s wrong with my brain?Human-Computer Interaction and the Stroop Test

Page 43: Teaching the Principles of Computer Science to Primary-Aged Children

Shout out the name of the color from top to bottom, left to right

Page 44: Teaching the Principles of Computer Science to Primary-Aged Children

Shout out the words from left to right, top to bottom.

Page 45: Teaching the Principles of Computer Science to Primary-Aged Children

Shout out the color of the words from left to right, top to bottom.

Page 46: Teaching the Principles of Computer Science to Primary-Aged Children

• To build good user interfaces we need to understand how we process information in our brain.

• The test you have just done is the Stroop Test - many find it very difficult.

• Artificial Intelligence

• Cognitive Science

• Psychology

• Many disciplines can come together

Why does this matter?

Page 47: Teaching the Principles of Computer Science to Primary-Aged Children

Running TogetherSorting, Data Structures, and Parallel Computing

Page 48: Teaching the Principles of Computer Science to Primary-Aged Children

• Sorting numbers (or any data) is a really important problem in computers.

• How do computers do things faster?

• We could figure out a better way of doing the calculation (algorithm)

• We could figure out how to represent the task a little better so we an then figure out a different method (data structure)

• We could do things at the same time (parallel computing)

• We’ll look at a games which we can play in the school year

What’s this all about?

Page 49: Teaching the Principles of Computer Science to Primary-Aged Children

A Sorting Network

72 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Sorting Networks

Prior to the activity use chalk to mark out this network on a court.

!"#$%&'$()"#*+)%*,-(./%0"!

This activity will show you how computers sort random numbers into order using a thing called a sorting network.

1. Organise yourselves into groups of six. Only one team uses the network at a time.

2. Each team member takes a numbered card.

3. Each member stands in a square on the left hand (IN) side of the court. Your numbers should be in jumbled order.

4. You move along the lines marked, and when you reach a circle you must wait

for someone else to arrive.

5. When another team member arrives in your circle compare your cards. The person with the smaller number takes the exit to their left. If you have the higher number on your card take the right exit.

6. Are you in the right order when you get to the other end of the court?

If a team makes an error the children must start again. Check that you have understood the operation of a node (circle) in the network, where the smaller value goes left and the other goes right. For example:

We compare numbers at the circles, smaller go one way, larger in the other

Page 50: Teaching the Principles of Computer Science to Primary-Aged Children

How does it work?

72 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Sorting Networks

Prior to the activity use chalk to mark out this network on a court.

!"#$%&'$()"#*+)%*,-(./%0"!

This activity will show you how computers sort random numbers into order using a thing called a sorting network.

1. Organise yourselves into groups of six. Only one team uses the network at a time.

2. Each team member takes a numbered card.

3. Each member stands in a square on the left hand (IN) side of the court. Your numbers should be in jumbled order.

4. You move along the lines marked, and when you reach a circle you must wait

for someone else to arrive.

5. When another team member arrives in your circle compare your cards. The person with the smaller number takes the exit to their left. If you have the higher number on your card take the right exit.

6. Are you in the right order when you get to the other end of the court?

If a team makes an error the children must start again. Check that you have understood the operation of a node (circle) in the network, where the smaller value goes left and the other goes right. For example:

Kate will demonstrate it with me...

Page 51: Teaching the Principles of Computer Science to Primary-Aged Children

Coloring InGraph Coloring, Combinatorics and Complexity Theory

Page 52: Teaching the Principles of Computer Science to Primary-Aged Children

What’s it about?

• A travel game for children: print out lots of maps (like the one on the right) and give your child four different crayons - and no more.

• For every map you give them, they should be able to color it so that no two countries that have a common border have the same color.

• Simple, but a very deep problem, which we’ll discuss a little shortly. But first...

Page 53: Teaching the Principles of Computer Science to Primary-Aged Children

The Poor Cartographer

He can’t afford very many colors!

Page 54: Teaching the Principles of Computer Science to Primary-Aged Children

Instructions: Color in the countries on this map with as few colors aspossible, but make sure that no two bordering countries are the samecolor.

From “Computer Science Unplugged”

c!Bell, Witten, and Fellows, 1998

Page 138

Kate - can you color this map with two colors? It might be difficult.

Page 55: Teaching the Principles of Computer Science to Primary-Aged Children

Instructions: Color in the countries on these maps with as few colorsas possible, but make sure that no two bordering countries are the samecolor.

From “Computer Science Unplugged”

c!Bell, Witten, and Fellows, 1998

Page 139

These maps can be coloured with three colors only.

Page 56: Teaching the Principles of Computer Science to Primary-Aged Children

• What if two children colored a map together - one tried to use very few colors, and other didn’t care, how many crayons do we need?

• We know 33 is enough, but it is believed at most 10 are needed. Nobody has proved it!

• Empires - two maps, a country of each is paired with a country from the other. Nobody knows how many colors we need!

Why is this deep?

Page 57: Teaching the Principles of Computer Science to Primary-Aged Children

• Four colors are always enough: conjecture in 1852, proved in 1976!

• Number of choices grows quickly as the number of countries increases, e.g. 50 countries in 1 hour; then 1 more country would take 4 hours; 10 more countries requires one year!

• The fundamental open question in computer science is: “Does P=NP?” We don’t know!

Why is this deep?

Page 58: Teaching the Principles of Computer Science to Primary-Aged Children

Card Flip MagicError Detection and Correction

Page 59: Teaching the Principles of Computer Science to Primary-Aged Children

• Kate put down 5x5 cards.

• My additional cards were placed to ensure that the number of pink cards in each row and column were even.

• When Kate changed something, my cards told me exactly what she did.

• Automatic error-checking and correcting key in finance, communications & security.

The Secret

Page 60: Teaching the Principles of Computer Science to Primary-Aged Children

What about actually using a computer, like?Programming stories, games, music and art for children

Page 61: Teaching the Principles of Computer Science to Primary-Aged Children

scratch - http://scratch.mit.eduProgramming stories, games, music and art for children

Page 62: Teaching the Principles of Computer Science to Primary-Aged Children

!"#$"%&'()*$+'!,-.&!"#$%&'()*"+,-).,)"/01)"

2$*"(3)"4$1-5067

Divide-n-ConquerAlgorithms

Page 63: Teaching the Principles of Computer Science to Primary-Aged Children

This book designed by

Computer Science Unplugged is licensed under a Creative Commons Attribution-Noncommercial-No!Derivative Works 3.0 License.

csunplugged.org orangestudio.co.nz

Credits

Page 64: Teaching the Principles of Computer Science to Primary-Aged Children

IV

‘Twas ten to midnight on December 24th and all was not well in the far, far North.

Page 65: Teaching the Principles of Computer Science to Primary-Aged Children

V

Some little elves were wrapping a thousand and twenty four toys, roller skates for a thousand and twenty four good girls and boys.

Page 66: Teaching the Principles of Computer Science to Primary-Aged Children

VII

At ten to midnight the elves called Saint Nick, tonight, all the boxes had been filled extra quick. Saint Nick was thrilled, “right then, fill up thesleigh, a thousand and twenty four boxes and weʼre on our way.”

Page 67: Teaching the Principles of Computer Science to Primary-Aged Children

VIII

Then Mrs. Christmas burst in through the doors “Where are your dirty socks, Santa Claus?”

Page 68: Teaching the Principles of Computer Science to Primary-Aged Children

IX

A young elf cried, “Santa, I dropped your dirty sockses in one of the thousand and twenty four boxes!”

Page 69: Teaching the Principles of Computer Science to Primary-Aged Children

XI

“Quick, unwrap every single box! Iʼm not leaving ʻtil you find those socks!” “Sorry, Santa,” said the supervisor elve, “us workers are all union, and we finish at twelve.”

Page 70: Teaching the Principles of Computer Science to Primary-Aged Children

XIII

Said Santa, “No need to be unpleasant, Iʼve got a big pair of scales, just weigh each present. Theyʼll all weigh the same when you put them in each bucket, except for one, and that oneʼs the culprit!”

Page 71: Teaching the Principles of Computer Science to Primary-Aged Children

XV

“With all due respect,” replied the supervisor elf, “Itʼll take a jolly long time, and you can do it yourself. If we could make one comparison every second, weʼd be here ʻtil twelve-oh-seven!”

Page 72: Teaching the Principles of Computer Science to Primary-Aged Children

XVI

A little elf piped up: “I’ve got an idea! We just need to use divide and conquer here.

Page 73: Teaching the Principles of Computer Science to Primary-Aged Children

XVII

Put half the boxes on that scale, and half the boxes on this, whichever side goes up, that pile we dismiss!”

Page 74: Teaching the Principles of Computer Science to Primary-Aged Children

XIX

The supervisor elf, with an unimpressed gaze, pointed out, “weʼll still be here for days. Youʼve narrowed it down to five hundred twelve, Hardly any help from this little elve.”

Page 75: Teaching the Principles of Computer Science to Primary-Aged Children

XXI

“Wait,” said the elf, only beginning his campaign, “watch what happens when we halve it again.” So they halved it again, and now their fix was narrowed to two hundred and fifty six.

Page 76: Teaching the Principles of Computer Science to Primary-Aged Children

XXII

Then, after their third comparison of weight, their problem was reduced to a hundred twenty eight.

Page 77: Teaching the Principles of Computer Science to Primary-Aged Children

XXIII

Then sixty four,

Page 78: Teaching the Principles of Computer Science to Primary-Aged Children

XXV

then thirty two...

Page 79: Teaching the Principles of Computer Science to Primary-Aged Children

XXVII

sixteen...

Page 80: Teaching the Principles of Computer Science to Primary-Aged Children

XXIX

eight...

Page 81: Teaching the Principles of Computer Science to Primary-Aged Children

XXXI

four...

Page 82: Teaching the Principles of Computer Science to Primary-Aged Children

XXXIII

two...

Page 83: Teaching the Principles of Computer Science to Primary-Aged Children

XXXV

...itʼs true! On the tenth comparison, with much joy, this elf had found the erroneous toy. A job that couldʼve gone well beyond the time limits took just a matter of minutes.

Page 84: Teaching the Principles of Computer Science to Primary-Aged Children

XXXVII

So the gift was replaced, the elves went home, and Santa was set for his world-wide roam. No poor child, far or near, will have to smell Santaʼs dirty underwear!

Page 85: Teaching the Principles of Computer Science to Primary-Aged Children

XXXIX

But first the little elf was approached by Saint Nick, “Where did you learn your clever trick?” The little elf replied “On magic I make no reliance, all I need to use is a little computer science.”

Page 86: Teaching the Principles of Computer Science to Primary-Aged Children

XL

!"#$%&'

Page 87: Teaching the Principles of Computer Science to Primary-Aged Children

Teaching the Principles of Computing to Primary-Aged Kids

Professor Barry O’Sullivanand Kate O’Sullivan (Age 9)