1

We all know the partitioning problem: Given a super-set S of integers, can we partition S into 2 subsets with the same sum. And of course this problem is NP-complete.

My question is - let's denote M as the sum of all numbers in S. Is O(M) considered to be polynomial in this case?

I will clarify: I want to prove that a certain problem is NP-hard, and in order to do so I use a reduction from partitioning that uses O(M) nodes in a graph. Is this considered to be a polynomial build?

  • 1
    https://en.wikipedia.org/wiki/Weak_NP-completeness, https://cs.stackexchange.com/q/51542/755, https://cs.stackexchange.com/q/71161/755, https://cs.stackexchange.com/q/84136/755, https://cs.stackexchange.com/q/60735/755 – D.W. May 14 '18 at 06:46
  • So in this case if my reduction is correct but is in O(M) it is not a polynomial reduction? – Naftali Waxman May 14 '18 at 06:53

1 Answers1

2

A Turing machine $T$ runs in polynomial time if there is a polynomial $p$ such that the running time of $T$ on an input of length $n$ bits is at most $p(n)$. The same definition works for other machine models such as the RAM machine.

Whether $O(M)$ is polynomial time or not depends on the way you encode the input. If the input is encoded in binary, then $O(M)$ isn't polynomial time, since the input could be of length as low as $O(\log M)$. If the input is encoded in unary (i.e., a number $x \geq 0$ is encoded as $1^x$) then $O(M)$ is polynomial time. It is part of the definition of the problem to specify the way the input is encoded.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503