O'Reilly logo
  • You Wang thinks this is interesting:

For example, 1 + 2 + 4 = 8 – 1, or 1 + 2 + 4 + 8 = 16 – 1, and so forth. This is, from one perspective, exactly why binary counting works. A binary number is a string of zeros and ones, each of which determines whether a given power of two should be included in a sum (starting with 20 = 1 on the far right). So, for example, 11010 would be 2 + 8 + 16 = 26. Summing the first h of these powers would be equivalent to a number like 1111, with h ones. This is as far as we get with these h digits, but luckily, if these sum to n–1, the next power will be exactly n.

From

Cover of Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition

Note

Knockout tournament, binary tree, and binary encoding, have the same inner structure. They are the same thing basically.