dcf.cymru stimulus sheet · Computer Science · Year 7

The six-wire sorting network

This network really does sort. It has twelve comparators arranged in five steps. Whatever six numbers go in on the left, they come out smallest-at-the-top on the right.

Cover teacher — how to use this sheet

Print one per pair for desk work. If you have floor space, chalk or tape the same shape onto the ground and have six pupils walk it holding number cards — each coloured bar is a place where two pupils meet, compare, and the smaller number takes the upper wire.

No computers are needed for any part of this lesson.

The network

Six-wire sorting network Step 1 Step 2 Step 3 Step 4 Step 5 IN 1 OUT 1 IN 2 OUT 2 IN 3 OUT 3 IN 4 OUT 4 IN 5 OUT 5 IN 6 OUT 6 Each coloured bar is one comparator: the two pupils it joins compare cards and the smaller number moves UP.

The three rules

  1. You only ever move along your own wire, from left to right.
  2. When you reach a coloured bar you must wait for the pupil at the other end of it. Show each other your cards.
  3. The smaller number takes the higher wire (nearer the top of the page); the larger number takes the lower wire. If the numbers are already in that order, nobody moves.

The twelve comparators written out

Wires are numbered 1 (top) to 6 (bottom). "(2,4)" means the pupils on wires 2 and 4 compare.

Step Comparators in that step (they all happen at the same time)
Step 1(1,6)   (2,4)   (3,5)
Step 2(2,3)   (4,5)
Step 3(1,4)   (3,6)
Step 4(1,2)   (3,4)   (5,6)
Step 5(2,3)   (4,5)

Card set A — heights of six Welsh mountains, in metres

Cut these out, shuffle them, and hand one to each of the six pupils on the wires.

CardMountainHeight
1Yr Wyddfa (Snowdon)1085 m
2Glyder Fawr1001 m
3Tryfan915 m
4Aran Fawddwy905 m
5Cadair Idris (Penygadair)893 m
6Pen y Fan886 m

Card set B — plain numbers

Use these if the mountain heights are too close together to compare quickly.

CardNumber
112
246
325
433
551
618