Skip to content

halving again and again

foundations

the puzzle

A 32 metre rope is cut in half, keeping one half, again and again. How many cuts until 1 metre is left?

a worked example

Halve the rope cut by cut, and count the cuts.

  1. After cut 1, 16 metres are left. Then 8, 4, 2 and 1.
  2. That is 5 halvings, so 5 cuts.
  3. 32=2532 = 2^5, so log⁡2 32=5\log_2\, 32 = 5. The count of halvings is the log.
  4. Undo it. Doubling 1 five times makes 32, so halving 32 five times makes 1.
rounding down321684215 halvings
32 metres halved to 16, 8, 4, 2 and 1, five cuts.

how it works

For a power of 2, n=2kn = 2^k, halving down to 1 takes k=log⁡2 nk = \log_2\, n halvings.

rounding down40201052.5 → 215 halvings
40 halved, rounding down, to 20, 10, 5, 2 and 1. That is 5 halvings, the same as 32, and log⁡2 40\log_2\, 40 lies between 5 and 6.

For other numbers, halve and round down with a floor (lesson 6.3) each time. 40 goes to 20, 10, 5, then ⌊2.5⌋=2\lfloor 2.5 \rfloor = 2, then 1, which is 5 halvings.

40 sits between 25=322^5 = 32 and 26=642^6 = 64. Halving all three keeps it between the next two powers. 20 lies between 16 and 32, 10 between 8 and 16, and 5 between 4 and 8. Then 2≤2.5<42 \le 2.5 < 4, where << means "is less than", and the floor, 2, is at least 2 but below 4. So it reaches 1 when 32 does, after 5 halvings.

In general, if 2k≤n<2k+12^k \le n < 2^{k + 1}, halving with floors takes kk steps, and k=⌊log⁡2 n⌋k = \lfloor \log_2\, n \rfloor.

in symbols

Doubling nn adds one halving, as log⁡2(2n)=1+log⁡2 n\log_2 (2n) = 1 + \log_2\, n (lesson 6.2). Making nn 64 times bigger is six doublings, as 64=2664 = 2^6, so it adds 6 halvings: 32 takes 5, and 32×64=204832 \times 64 = 2048 takes 5+6=115 + 6 = 11.

A sorted list is in order, smallest first. In a sorted list, one look at the item halfway along tells which half holds the one you want, and the other half goes. 16 items take 4 looks, as 16 halves to 8, 4, 2 and 1, so halving each look takes about log⁡2 n\log_2\, n looks. Checking items one by one may need all nn.

list made this many times longersearch steps added
21
325
102410
Steps grow by the log of the factor, never by the factor.

your turn

Work each one out. Where there is a box, type your answer and check it. Each exercise's worked answer opens under it.

exercise 1

A stack of paper is halved again and again, and after 9 halvings 1 sheet is left. Each halving was exact.

A number, like 13, 9.5 or 19/2.

worked answer
  1. Undo the halvings by doubling 1 nine times. That is 292^9.
  2. 29=5122^9 = 512, so the stack had 512 sheets, and log⁡2 512=9\log_2\, 512 = 9.

Check it another way: 512 halves to 256, 128, 64, 32, 16, 8, 4, 2, 1, which is 9 halvings.

exercise 2

Halve 100 again and again, rounding down each time.

A number, like 13, 9.5 or 19/2.

worked answer
  1. 100 goes to 50, then 25.
  2. ⌊12.5⌋=12\lfloor 12.5 \rfloor = 12, then 6, then 3.
  3. ⌊1.5⌋=1\lfloor 1.5 \rfloor = 1. That is 6 halvings.

Check it another way: 26=64≤100<128=272^6 = 64 \le 100 < 128 = 2^7, so ⌊log⁡2 100⌋=6\lfloor \log_2\, 100 \rfloor = 6.

exercise 3

Halving one pile down to 1 takes 9 steps, and a second pile takes 13. Both are powers of 2.

A number, like 13, 9.5 or 19/2.

worked answer
  1. 13−9=413 - 9 = 4 extra halvings.
  2. Each one doubles the pile, so the second pile is 24=162^4 = 16 times bigger.

Check it another way: 213=81922^{13} = 8192 and 29=5122^9 = 512, and 8192÷512=168192 \div 512 = 16.

exercise 4

Some searches rule out half each step; some cannot.

The one that throws half away each step:

A number, like 13, 9.5 or 19/2.

worked answer
  1. Guess halfway, such as 32. Each answer says which side the number is on, so that half goes.
  2. In a messy drawer or a jar, looking in one spot says nothing about the rest.
  3. An unsorted list may hide the item anywhere, so all 64 may have to be looked at.

Check it another way: Only the higher-or-lower answers let one guess drop a whole side.