Encoded Input Length and Numeric Magnitude

A numeric value can be much larger than the number of bits needed to write it. Complexity claims depend on the chosen input encoding.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a doubling
  2. Name which measure is varied
  3. Compare runtime measured in value and encoded length
  4. State the representation before assigning a growth rate

Trace a doubling

The value \(2^{10}\) is 1024 but needs eleven binary digits. Counting one step for each integer up to it grows exponentially in the bit-length parameter. See binary notation.

Name which measure is varied

An algorithm polynomial in a numeric amount is not automatically polynomial in the length of its encoding. Pseudopolynomial dynamic programming provides a concrete family.[1]

Compare runtime measured in value and encoded length

A loop with \(N\) iterations takes time proportional to the numeric value under a unit-cost step model. If the only input is \(N\) in binary, its length is about \(\log_2 N\). Powers of two make the contrast easy to see. See arithmetic cost and word size.

N=8 → binary 1000, length 4, 8 iterations
N=16 → binary 10000, length 5, 16 iterations
Each added bit in this series doubles loop work

State the representation before assigning a growth rate

If the input explicitly lists \(N\) distinct items, reading them already costs linear work in the item count. A binary quantity and a whole collection describe very different input sizes.

References

  1. Michael Sipser, Introduction to the Theory of Computation ↩