Codepiko · Computer science: Sorting and searching
Sort and find
Goal: Sort by comparing, and search fast by looking in the middle.
Time: 35 min · You need: Pencil; for class play, chalk or floor tape
1. Sorting network
Numbers travel left to right along the wires. Where a line joins two wires, compare the two numbers: the smaller moves to the upper wire, the larger to the lower wire. After each column, write the numbers in the boxes.
2. Hidden number
A friend picks a number from 1 to 100. After every guess they say “higher” or “lower”. Write your guesses in the table. Then swap. Who found it in fewer guesses?
| # | Guess | What did your friend say? |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 |
codepiko.com