Data Structures & AlgorithmsVery hardICPC regional · graph theory

Problem: Which claim about the complexity of deciding 2-SAT (satisfiability of clauses with at most two literals) is correct?

  1. A. It is solvable in linear time O(n + m) via strongly connected components of the implication graph
  2. B. It is NP-complete, so no polynomial algorithm is known
  3. C. It needs exponential time in the number of variables
  4. D. It is solvable only with dynamic programming over all 2^n assignments

Correct answer: A. It is solvable in linear time O(n + m) via strongly connected components of the implication graph

Each clause a OR b gives implications not a -> b and not b -> a, and the formula is satisfiable exactly when no variable shares an SCC with its negation. 3-SAT, not 2-SAT, is NP-complete.

More Coding Interview Problems questions

Exams that ask this topic