Binary encoding represents a number
This compactness is usually treated as a harmless implementation detail, but it is not. It reshapes the boundary between tractable and intractable.
The Hidden Exponential
A dynamic programming algorithm for the subset sum problem runs in
A dynamic programming table with dimensions
be the bit-lengths of the two numeric fields. Then
so the total number of cells is
The algorithm is polynomial in the numeric values
Bi Knapsack is a concrete instance of this pattern. Its dynamic programme uses a table
This is polynomial in the numeric capacities, but not necessarily polynomial in the encoded input. For instances with
capacity states. This is the exact sense in which the dynamic programme is pseudo-polynomial.
When Encoding Does Not Matter
Not every problem is rescued by unary encoding. A strongly NP-hard problem remains intractable even when every numeric parameter is bounded by a polynomial in the input length. The hardness comes from combinatorial structure, not from numeric magnitude.
Consider the travelling salesman problem. Its input is a graph with
The weights are tiny, but the number of tours grows factorially. Unary encoding makes the weight labels longer, yet the permutation space is unchanged. The algorithm must still enumerate an exponential number of structures.
The Quantity Space
The clean dichotomy has a deeper cause. The question is whether the problem’s difficulty comes from iterating over a space whose size is a direct function of the numeric values themselves.
For the subset sum problem, the dynamic programming table has dimensions
The function is essentially the identity on the numeric value. Because binary encoding compresses
For the travelling salesman problem, the search space is the set of all permutations of vertices:
The edge weights are merely coefficients in the objective function. Restricting weights to
Even if we treat
Uniform Polynomial Bounds
Fix an encoding of problem instances, and let
The encoding is fixed for the problem. It is not chosen separately for each instance. Polynomial-time solvability is stable under standard encodings whose lengths are polynomially related. Binary and unary encodings of numeric values are not polynomially equivalent, since a value
The exponent
That would be meaningless: almost any finite runtime can be bounded this way by choosing a large enough instance-dependent exponent.
Now let
Every non-negative integer satisfies
If such a
Minimum Search
For minimum search, the input is an explicit array
Here
. Since the instance explicitly contains entries, So we can choose the fixed exponent
: A linear scan therefore satisfies
This is polynomial-time with the fixed exponent
.
Subset Sum
For subset sum, the input contains a target value
as one binary field: Here
. The field has length There is no fixed exponent
such that For every fixed
, one can choose an instance with so large that Equivalently,
may be linear in , so may be exponential in the input length. The dynamic programming algorithm creates
columns, so which is not bounded by
for any fixed .
Summa summarum:
So the point is not that
Beyond NP-Hardness
This gives the clean dichotomy. For weakly NP-hard problems, the hardness lives in the encoding gap because the state space grows with the numeric value. For strongly NP-hard problems, the hardness lives in the combinatorial structure, and no amount of decompression can remove it.
This means the complexity class of a weakly NP-hard problem can depend on how its input is written. The hardness can come from numeric parameters being compressed efficiently. Remove the compression, and that source of hardness disappears.
Therefore, binary encoding is not just compact—it is the source of the exponential gap that makes weakly NP-hard problems intractable.