28

This question was inspired by a comment on StackOverflow.

Apart from knowing NP-complete problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one?

I am not looking for something rigorous, but to something that works in most cases.

Of course, every time we have to prove that a problem is NP-complete, or a slight variant of an NP-complete one; but before rushing to the proof it would be great to have certain confidence in the positive result of the proof.

Vitaly Olegovitch
  • 1,248
  • 1
  • 14
  • 21

2 Answers2

19

This is my personal approach to determine whether a problem (i.e. a language $L$) is NP-complete or not. If both these conditions are verified:

  • I feel that testing if an instance $I$ is in $L$ implies that I need to check all combinations of some sort
  • and that there is no way to split such a combination into two smaller ones

then $L$ may very well be NP-hard.

For example for the subset sum problem, I have to list all subsets of $S$ and check if there is one whose sum is zero. Can I split $S$ into two smaller subsets $S_1$ and $S_2$ on which I will check a similar property? Humm... not really. Maybe if I checked for all combination of $S_1$ and $S_2$ but that would be really long...

Usually the ability to break into smaller pieces is a good indicator for a problem to be in P. This is the divide and conquer approach. For example to find the shortest path between two points, you can use the property that if the shortest path from $A$ to $C$ go through $B$ then it is not longer than the shortest path from $A$ to $B$ plus the shortest from $B$ to $C$.

Quite frankly this approach is very basic: I try to find a (polynomial) algorithm for the given problem. If I can't find one then the problem becomes "hard" in my point of view. Then comes all the NP-completeness reasoning: will I be able to encode an existing NP-complete problem into this one? (And since this is usually much harder, I try once more to find a polynomial algorithm..)

I suspect that this is the usual way of thinking. However it remains quite hard to apply on unknown problems. I personally remember being surprised by one of the first examples of NP-completeness I was told: the clique problem. It seemed so simple to check! So I suppose that experience has a lot to do with it. Also intuition can be useless sometimes. I remember being told several times two almost identical problems but one was in P and the other one with a small variation was NP-complete.

I am yet to find a good example (I need help here), but this is like the post correspondence problem: this is an undecidable problem but some variants are decidable.

jmad
  • 9,578
  • 1
  • 40
  • 43
15

Another perspective on problem-hardness comes from the game and puzzle community, where the rule of thumb is that 'problems are as hard as they possibly can be' (and the exceptions come from hidden structures in the problem - Massimo's example of the determinant in comments is a good instance of this); the trick then comes in understanding how hard a problem can be:

  • Puzzles involving the existence of a static configuration are in NP, and so they tend to be NP-complete; for instance, the polyomino packing problem (can a given set of $n$ polyominos pack a given rectangle of the appropriate area?) is NP-complete.
  • Puzzles involving a sequence of moves within a bounded state space are in PSPACE (since the 'move tree' can generally be explored in standard depth-first manner needing only storage for a polynomial number of configurations), and tend to be PSPACE-complete; a classic example of this is Rush Hour.
  • Games with a polynomially bounded depth are also in PSPACE; this uses the characterization of PSPACE as APTIME, since the usual min-max characterization of strategies perfectly mimics an alternating Turing machine with its characterization as 'there exists a move for player A such that for each reply move from player B, there exists a reply move for player A such that...', etc. They also tend to be PSPACE-complete; Hex and generalized Tic-Tac-Toe games are both examples of this.
  • Games without a bound on tree depth but played in a (polynomially) bounded space are in EXPTIME, since there are exponentially many total positions and the entire graph can be built and explored in time polynomial in the number of positions (and thus exponential overall); these games are generally EXPTIME-complete. Chess, Checkers, and Go all fall into this category.
Steven Stadnicki
  • 2,539
  • 15
  • 25