Questions tagged [pseudo-polynomial]
37 questions
17
votes
3 answers
Why not to take the unary representation of numbers in numeric algorithms?
A pseudo-polynomial time algorithm is an algorithm that has polynomial running time on input value (magnitude) but exponential running time on input size(number of bits).
For example testing whether a number $n$ is prime or not, requires a loop…
M a m a D
- 1,561
- 2
- 18
- 33
15
votes
2 answers
Why is the dynamic programming algorithm of the knapsack problem not polynomial?
The dynamic programming algorithm for the knapsack problem has a time complexity of $O(nW)$ where $n$ is the number of items and $W$ is the capacity of the knapsack.
Why is this not a polynomial-time algorithm?
I have read that one needs $\lg W$…
Kaalouss
- 477
- 1
- 4
- 7
10
votes
1 answer
Could this be an NP-Complete problem?
Consider the following problem statement:
Given an initial number, you and your friend take turns to subtract a perfect square from it. The first one to get to zero wins.
For example:
Initial State: 37
Player1 subtracts 16. State: 21
Player2…
Martin Copes
- 201
- 1
- 4
8
votes
2 answers
Do I understand pseudo polynomial time correctly?
The running time of knapsack is $O(n*W)$, but we always specify that this is only pseudo-polynomial. I was wondering if somebody could tell me if I understand the notion of pseudo-polynomial time correctly.
My current understanding is that pseudo…
Maksim
7
votes
2 answers
Weak and strong completeness
What does a pseudo-polynomial algorithm tell us about the problem it solves? I don't see how running time improves if the algorithm is exponential in the input length and polynomial in the input value; so how do we explain this shift from…
mrk
- 3,748
- 23
- 35
6
votes
2 answers
Shouldn't every algorithm run in pseudo-polynomial time?
Wiki says
a numeric algorithm runs in pseudo-polynomial time if its running time is polynomial in the numeric value of the input, but is exponential in the length of the input – the number of bits required to represent it.
This answer very well…
Ritwik
- 205
- 1
- 8
3
votes
1 answer
Solving a variant of the Exact cover problem
I am trying to solve a variant of the Exact cover problem where every element has to be covered exactly twice instead of once ( i.e. has to be in exactly two sets that are part of the cover).
Now, it is clear to me that this is an NP-complete…
Ron Tubman
- 41
- 2
3
votes
0 answers
Is there a pseudo polynomial time algorithm for this 0-1 quadratic subset sum problem?
Say that we have some (integer) weights $w_{1,1},w_{1,2},...,,w_{m,m}$ and a target sum $W$.
Suppose that we want to find whether there are $a_1,...,a_m \in \{0,1\}$ such that
$$\sum_{i = 1}^{m} \sum_{j = i}^m a_i a_j w_{i,j} = W.$$
I read through…
Kevin
- 168
- 5
3
votes
2 answers
Why addition algorithm is not pseudo- polynomial?
There is something I don't understand.
In the Subset Sum problem, in the Dynamic Programming solution, because of binary representation of the sum T, we say it is pseudo-polynomial in run time; we must sum in the worst case from 1 to T.
So I don't…
Pedro
- 397
- 4
- 13
3
votes
2 answers
Is there an NP-hard problem that becomes polynomial when the inputs are at most $2^n$?
Let Q be a computational problem that accepts as input some $n$ non-negative integers. Is it possible (assuming $P\neq NP$) that Q is NP-hard in general, but can be solved in polynomial time when restricted to inputs in the range $[0,2^n]$?
If,…
Erel Segal-Halevi
- 6,088
- 1
- 25
- 60
3
votes
2 answers
Knapsack Problem with exact required item number constraint
How would we solve the knapsack problem if we now have to fix the number of items in the knapsack by a constant $L$? This is the same problem (max weight of $W$, every item have a value $v$ and weight $w$), but you must add exactly $L$ item(s) to…
Bryce219
- 48
- 1
- 5
2
votes
1 answer
How is integer factoring not in $P$?
Everyone keeps claiming that integer factoring is in $NP$ but I just don't get it... Even with the simplest algorithm (division with all integers up to $\sqrt{n}$) the complexity should be $\sqrt{n}\log(n)$... How is that not in $P$? Is there…
Confused
- 23
- 2
2
votes
1 answer
Common subset sum fast algorithm
Suppose of I two sets of $n$ integers bounded in $[-B,B]$. The integers are $$a_1,\dots,a_n$$
$$b_1,\dots,b_n$$
I want to find if there is a common subset $I\subseteq\{1,\dots,n\}$ such that $$\sum_{i\in I}a_i=0$$$$\sum_{i\in I}b_i=0$$
This problem…
user39969
2
votes
1 answer
Whats is the meaning of polynomial run-time in input size ?
If an algorithm runs in exponential time with exponential input then we say it runs in polynomial time ?
Why ?
Doesn't the algorithm run in exponential time anyway ?
How the input size affects ?
Thanks.
user27500
- 23
- 1
- 3
2
votes
1 answer
Expressing pseudo-polynomial runtime solely in terms of the input size
In case we have an algorithm which is pseudo-polynomial and runs in $O(n^2C)$ for some $C$ that is encoded in binary. Is it correct to say that if $C=2^n$ then $O(n^2C)=O(n^22^n)$
and because $n=\log C$ we can write that $O((\log C)^22^n)=O(2^n)$…
Tony_Pizzacata
- 23
- 2