Worked example · Languages, Literacy and Communication · Year 3

Debugging a library shelving algorithm

DCF: Data and computational thinking → Problem-solving and modelling

Also assessed, LNF: Numeracy → Number system → The number system

What this is

A complete, secure Year 3 answer with the full answer key. Pupils’ wording for the bugs and the new rule will differ; accept any answer that would make the algorithm work. The finished shelves are drawn below so you can check at a glance.

Step 1

BookLabelShelf
1796Non-fiction
2DAHStory
3523Non-fiction
4942Non-fiction
5WILStory
6398Non-fiction
7597Non-fiction
8MORStory
9591Non-fiction
10DONStory

Story shelf: 4 books. Non-fiction shelf: 6 books. (4 + 6 = 10, so no book is missed.)

Step 2: the finished non-fiction shelf

398Welsh myths and legends523The planets591Animals of Wales597Frogs and fish796Rugby skills942History of Wales

398 < 523 < 591 < 597 < 796 < 942

Hardest two: “591 and 597, because they both have 5 hundreds and 9 tens, so I had to look at the ones. 1 is less than 7.”

The pupil compares hundreds first, then tens, then ones, and explains it. This is the key numeracy evidence: ordering numbers up to 1000. Evidences success criterion 4.

Step 3: the finished story shelf

DAHThe BFGDONThe GruffaloMORKensuke’s KingdomWILThe Story of Tracy Beaker

DAH, DON, MOR, WIL (Dahl, Donaldson, Morpurgo, Wilson). DAH comes before DON because the second letter, A, comes before O.

Step 4: the bugs

a) 597 and 591 are the wrong way round. 591 is smaller, so it must go on the left of 597.

b) The bug: “Step 4 says stop straight away, so Gareth never goes back for the next book. Only the first book gets put away.”

New step 4: “Are there any more books in the pile? Yes: go back to step 1. No: stop.”

The pupil explains why the algorithm fails, then adds the missing repeat (a loop) that is in the flowchart. Evidences success criterion 2.

Step 5

a) 597: five hundred and ninety-seven. 942: nine hundred and forty-two.

b) seven hundred and ninety-six: 796. three hundred and ninety-eight: 398.

c) Easy cooking 641 goes between 597 and 796. Welsh rugby stars 796 goes next to Rugby skills (796), between 597 and 942, because it has the same number. Dinosaurs 567 goes between 523 and 591.

Correct spelling of the number words (ninety, forty) and correct placing of all 3 new books show secure reading, writing and comparing of 3-digit numbers. The equal number, 796, is the hardest: books with the same number simply sit together. Evidences success criteria 4 and 5.

Step 6

New questionIs the book written in Welsh?
If the answer is yesPut it on the Cymraeg shelf, then go to “Any more books in the pile?”
It goes after the box“Pick up the top book from the pile”, before the number question. If the answer is no, carry on to “Does it have a number on the spine?”

The new question must come before the number question, or Welsh information books would end up on the non-fiction shelf. A pupil who spots this has really understood that the order of steps matters. Evidences success criterion 3.

If you finish early: answers

600 is closest to 597 (3 away; 641 is 41 away). 942 is 42 more than 900. 398 is 2 less than 400.

What to look for