Skip to content
Exit presentation

Computational Thinking II

Look at the middle

The 12 cards are sorted, in order, smallest first. Look at the middle card. Is it too small? Keep the half with bigger numbers.

The range is the cards that could still be the one.

12 places in range.
Step 1 of 5
  1. 12 places in range.
  2. Place 6 is too small. 6 left.
  3. Place 9 is too small. 3 left.
  4. Place 11 is too small. 1 left.
  5. Place 12: found. 4 looks.

The rule

Halving means checking the middle and dropping half. Dropping a card means you no longer look at it.

A jumbled row is not in order. A middle look on a sorted row drops about half the cards. On a jumbled row, it can drop the wrong half.

In a sorted row, every card before the middle is smaller. So a wanted card must lie after a too-small middle.

Looks in the worst case

Most looks needed, one by one and by halving
CardsOne by oneHalving
443
16165
1000100010

The bigger the row, the more halving saves.

Halve the row. Then try the jumbled one.

Loading lab…

Jump to lesson

This track

  1. 0 Start here
  2. 1 Steps written, steps taken
  3. 2 Look at the middle
  4. 3 Ovals, boxes and diamonds
  5. 4 Give every case an answer
  6. 5 Predict, run, compare
  7. 6 The big picture
  8. 7 Track quiz

Other tracks