3

If an algorithm's input size is 2^n and the algorithm runs in $O(n2^n)$ time. In this case, can we say that the algorithm runs in polynomial time with respect to input size?

NARAYAN CHANGDER
  • 319
  • 4
  • 13

1 Answers1

6

Yes, that would be an O(k log k)-time algorithm, where k = 2^n.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • Thanks, @David So, I could say it is a polynomial time or pseudopolynomial? I am confused between these two. – NARAYAN CHANGDER Jan 27 '17 at 14:53
  • A good question and a good answer - everything depends on the right definitions; I always found it somewhat puzzling that, for instance, for matrix multiplication algorithms, the runtime bound is usually stated in terms of `n` where the input is of size `n*n`. – Codor Jan 27 '17 at 14:53
  • @NARAYANCHANGDER Polynomial. An example of a pseudopolynomial running time is O(k^log k). – David Eisenstat Jan 27 '17 at 14:57