According to this answer, given input $2^n$ (and thus input size $n$), this problem is not computable by a deterministic Turing machine in number of steps polynomial in the input size (though it is polynomial time computable under the Arithmetic model). Does this imply that the decision version of the problem is not in $P$?
1 Answers
You did not specify what is the decision version of the problem you are interested in. I assume that it is the following:
Input: A pair $\langle x, k \rangle$ Where:
- $x$ is an integer of the form $2^n$ for some non-negative integer $n$ (encoded in base $2$).
- $k$ is a positive integer.
Notice that the input size is $\Theta(n + \log k)$.
Output: True if $2^x \le k$, false otherwise.
This problem is in $\mathsf{P}$. You can compute $2^x$ by iteratively multiplying $2$ up to $x$ times. As soon as the current product exceeds $k$, return false. If this is not the case after the $x$-th iteration, return true.
Notice that, in each iteration, the current product is at most $2k$. Therefore a single iteration can be implemented in time $O(\log k)$. There are at most $O(\log k)$ iterations (since the product doubles at each iteration) and hence the overall time spent is $O(n + \log^2 k)$, which is polynomial in the input size.
- 29,724
- 2
- 29
- 49