Sorting algorithms for 9-year-olds

Author: Eilidh Troup
Posted: 20 May 2014 | 11:54

At St Peter's primary school recently I had a go at teaching the P4 and 5s (8-10 year olds) about what computers really do, in particular sorting and searching algorithms.

Working with groups of about 8 children, I gave them each a numbered ball, told them that I wanted to organise them into a line from lowest to highest number and tried to use the quick sort algorithm by taking one child as the pivot, and dividing the rest of the children into smaller or larger numbers on either side. At which point I should be able to repeat the process on each side until they're sorted. This didn't work, as the children sorted themselves, and when I asked if they could see what I was trying to do, I was met with a flat 'no'. Searching worked a bit better, and the children got the idea that it was much faster to search for a number in a sorted list than in an unsorted one.

Fortunately the nursery school were having a coffee morning, so fuelled by tea and home-baking I tried a new strategy with the next class after the break.

I gave one child at a time a ball and got them to take their correct place in the line (insertion sort) which came very naturally. Then we did a couple of searches, with the searching child having to pay a token to look at a number. They could usually find it in about two goes. Then I introduced the idea that computers are not actually very clever and can only follow simple instructions, like comparing 2 numbers and swapping them, so I pretended to be a processor, swapping pairs of children holding numbers around until they were sorted (bubble sort).

At this point, if there was time left in that session, I told them about supercomputers using lots of processors at once to do calculations like compare and swap, and we did the bubble sort again with the children comparing themselves in pairs and deciding whether to swap or not. This worked pretty well and was faster, which is a nice result. 

The children seemed to enjoy themselves and might even have learned something. As for me, I've lost my voice.


Eilidh Troup

Blog Archive