Pseudo-polynomial time (source code)

= Pseudo-polynomial time
{wiki}

= Pseudopolynomial time
{synonym}

= Pseudopolynomial
{synonym}

An <algorithm> has <pseudo-polynomial time> when its <running time> is bounded by a <polynomial> in the numerical magnitudes of <input> quantities, rather than necessarily in their encoded lengths. The <dynamic programming> table for the <0-1 knapsack problem> uses $O(nW)$ arithmetic operations for $n$ items and capacity $W$.

A <binary numeral system> representation needs only $O(\log(W+1))$ <bits> for that capacity, so the table bound can be exponential in the number of capacity <bits>. For example, capacities below $2^b$ fit in $b$ <bits>, while a table with one entry for every capacity can have nearly $2^b$ columns. The numerical-value bound does not claim that every instance requires exponential work.