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,905
  • 7
  • 63
  • 117

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
  • 82,470
  • 26
  • 145
  • 239
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.
  • 167,959
  • 22
  • 232
  • 500