Computers spend a huge amount of time doing two jobs: putting things in order and finding things. At Sorting Station, Year 3 coders learn how a bubble sort swaps its way to a tidy list, and why a sorted list can be searched in just a few clever guesses.
What your child will learn
- Say whether a list is sorted, and in which order
- Follow a bubble sort: compare two neighbours and swap them if they are the wrong way round
- Describe a linear search and a binary search
- Explain why a binary search needs a sorted list
Bubble sort: compare and swap
A bubble sort walks along the list looking at two neighbours at a time. If they are in the wrong order, it swaps them. After one walk the biggest number has “bubbled” to the end. Keep walking until no swaps are needed and the list is sorted.
Two ways to search
A linear search checks every item in turn — simple, but slow for a long list. A binary search looks in the middle of a sorted list and throws away the half that can’t hold the answer, again and again. Guessing a number from 1 to 100 takes at most seven guesses this way.
Example questions
Here are a few questions like the ones in the first quest. Can you solve them?
1. One swap puts 1, 3, 2, 4 in order. Which two numbers swap?
- 3 and 2
- 1 and 3
- 2 and 4
- 1 and 4
Show answer
Answer: 3 and 2. Swap 3 and 2 to get 1, 2, 3, 4.
2. To sort 3, 1, 2 from smallest to biggest, which number goes first?
- 2
- 3
- 1
Show answer
Answer: 1. 1 is the smallest, so it goes first: 1, 2, 3.
3. What does sorting mean?
- Deleting things
- Counting things
- Mixing things up
- Putting things in order
Show answer
Answer: Putting things in order. Sorting arranges items in order, such as smallest to biggest.
Tips for grown-ups
- Sort a shuffled hand of number cards using only neighbour swaps, and count the swaps.
- Play “guess my number” with higher and lower, always guessing the middle.
- Find a word in a dictionary by opening it in the middle and halving each time.