1

So In a review section, our professor asked:

Given integers $N$ and $M$

Is $O(N+M)$ exponential or polynomial.

It's exponential, but I just don't see how that is. I would have thought it's linear.

Juho
  • 22,554
  • 7
  • 62
  • 115

2 Answers2

8

Exponential or polynomial in what? As stated, it's clearly polynomial in $M$ and $N$.

The complexity of algorithms is given in terms of the length of the input. If an algorithm receives $M$ and $N$ as input, written in binary, then $M+N = O(2^\ell)$, where $\ell$ is the length of the input in bits.

You should ask your professor for clarification. S/he knows what s/he actually said and what the context was; we're just guessing.

David Richerby
  • 81,689
  • 26
  • 141
  • 235
3

There must have been some miscommunication. It's not exponential, unless there is some additional context that we're missing. (e.g., if $M=2^N$, then $N+M=O(2^N)$ is exponential in $N$)

D.W.
  • 159,275
  • 20
  • 227
  • 470