We often hear about some algorithms' running time that is polynomial, and some algorithms' running time that is exponential. But is there an algorithm whose time complexity is between polynomial time and exponential time?
4 Answers
There is a category of time complexity called quasi-polynomial. It consists of a time complexity of $2^{\mathcal{O}(\log^cn)}$, for $c> 1$. It is asymptoticaly greater than any polynomial function, but lesser than exponential time.
Another category is sub-exponential time which name speaks for itself. It is sometimes defined as $2^{o(n)}$.
The problem of graph isomorphism can be solved in sub-exponential time, but no algorithm in polynomial time is known.
- 18,309
- 2
- 30
- 58
The general number field sieve, the most efficient known algorithm for factoring large numbers, has a runtime that's roughly $\exp(n^{1/3})$, where $n$ is the number of digits in the number to be factored. This runtime grows with $n$ faster than any polynomial, but slower than exponential.
This class of runtimes is generally still considered "hard" for the purposes of practical computation (hence the security of RSA and other cryptography systems that depend on the difficulty of factoring). The cutoff for "practically efficient to compute" is generally taken to be right above polynomial growth, not right below exponential growth.
- 1,174
- 7
- 16
Other answers have given some specific examples of problems whose difficulty is conjectured to be between polynomial and exponential time, but the Time Hierarchy Theorem gives a general proof that for any time-constructible function $f(n)$, there is some decision problem which can be solved in time $f(n) \cdot log^2(n)$ but not in time $f(n)$.
Namely: Given an encoding of a Turing machine $M $and an input $x$, does $M$ accept $x$ within $f(|x|)$ steps?
So taking $f(n) = 2^{\sqrt{n}}$, the problem of deciding whether an arbitrary Turing machine halts within $2^{\sqrt{n}}$ is solvable in time $ n \cdot 2^{\sqrt{n}}$, but not solvable in time less than $2^{\sqrt{n}}$.
- 258
- 2
- 8
Sure, eg you can easily built an algorithm taking $\Theta(2^{\sqrt{n}})$ steps, and this is slower than polynomial but faster than exponential. For this, compute $\frac{2^{\sqrt{n}}}{\sqrt{n}}$ (in binary), and then count down from there, making sure to make a full pass through the array each time.
If you just want something intermediate, you can make it even simpler and just generate an array of length $\sqrt{n}$ and count up from $00\ldots 0$ to $11\ldots 1$. This clearly takes at least $2^{\sqrt{n}}$ steps, and at most $\sqrt{n}2^{\sqrt{n}}$.
- 3,559
- 14
- 25