-1

I developed an algorithm but just not sure what is the complexity of the algorithm. I provide a brief description of it below:

"For $N$ user case, there are $B(N)$ Decision Variables. $B(N)$ is Bell Number, for those of you who are not familiar with Bell Numbers please be noted that $B(N)$ grows exponentially with $N$. In every turn, I have to choose the minimum Decision Variable among all of the Decision Variables and do a certain action accordingly."

I know that sorting problem is considered a Polynomial $(P)$ problem. But I am confused if my algorithm is considered $P$ or $NP$ or $NP-hard$ since the number of decision variables that are being sorted grows exponentially with $N$.

Nadi
  • 1
  • 1

1 Answers1

3

Your question is somewhat malformed because P and NP are classes of problems, not algorithms. For example, as you state, the problem of sorting is in P. However, that doesn't mean that every sorting algorithm runs in polynomial time. For example, the well-known joke algorithm bogosort sorts lists by trying every possible permutation until it finds one that is sorted. It has running time approximately $n!$, which is far from polynomial. If a problem has polynomial time complexity, that means that there exists an algorithm that solves it in polynomial time, but it doesn't mean that all algorithms for the problem are that efficient.

It's not possible to say what the complexity of your problem is, or what the running time of your algorithm is, because you haven't given a precise description of either. The fact that it involves choosing a "best" set from some exponentially large set doesn't necessarily mean the problem has to have exponential time complexity: there could be a smart way of picking the best set without considering all the options. For example, there are polynomial-time algorithms for finding the shortest path between two points in a graph, even though there may be exponentially many paths.

David Richerby
  • 82,470
  • 26
  • 145
  • 239