I think the following problem belong to class P, but I don't know how I can prove it, could somebody help me?
- Inputs: two numbers $(a,b) \in \mathbb{N}$
- Output: $a^b$
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityI think the following problem belong to class P, but I don't know how I can prove it, could somebody help me?
Your problem is not in P, for two different reasons:
P is a class of decision problems, but your problem is a function problem. Instead of P, you should consider its functional equivalent FP.
The output could be exponentially large in the input length: encoding $b$ takes about $\log b$ bits, but encoding $a^b$ takes about $b \log a$ bits.
This still leaves open the possibility that the following problem is in P:
Given natural numbers $a,b$ and an index $i$, determine the $i$th bit of $a^b$.
While I don't know what the answer to this question is, here is a related problem in FP:
Given natural numbers $a,b,c$, determine $a^b \bmod c$.
This can be shown using the important technique of repeated squaring.