Pseudo-polynomial algorithms
Equality of numbers
- in both binary and unary coding
Primality test
- is divisible by
- sub-linear complexity with unary coding of
- exponential complexity with binary coding of
Subset sum
- INPUT: a set of numbers, number
- GOAL: subset of numbers from such that their sum is equal to
- ALGORITHM: test every subset,
- input (1, 1, 1, 1, 1, 1, 1, 1) vs ()
- (1, 1, 1, 1, 1, 1, 1, 1) ->
#1#1#1#1#1#1#1#1
- () ->
11111111
- (1, 1, 1, 1, 1, 1, 1, 1) ->
- the same length of the input, but different complexity!
We want to better characterize the input:
- define an integer problem
- characterize the input by length of the input (binary) + maximal number in the input
Algorithm is pseudo-polynomial if for every
Knapsack problem
- - number of items
- - sum over all
There exist a strong NP-hard problems that cannot be solved by pseudo-polynomial algorithm, e.g. TSP.