VOOZH about

URL: https://www.geeksforgeeks.org/dsa/proof-that-collinearity-problem-is-np-complete/

⇱ Prove that Collinearity Problem is NP Complete - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Prove that Collinearity Problem is NP Complete

Last Updated : 9 Apr, 2026

Problem: Prove that Collinearity Problem is NP-Complete for n Points. An instance of the collinearity problem is a set of n points ((ax, ay), (bx, by), (cx, cy), ...).

Since NP-Complete means both in NP and NP-Hard, the proof for the statement that a problem is NP-Complete consists of two parts:

  1. The problem itself is in NP class.
  2. All other problems in NP class can be polynomial-time reducible to that. (B is polynomial-time reducible to C is denoted as B ≤ P^C)

If only the 2nd condition is satisfied then the problem is called NP-Hard. Since it is not possible to reduce every NP problem into another NP problem to show its NP-Completeness, we instead prove that the problem is in NP and that any known NP-Complete problem is reducible to it. If both conditions hold, the problem is NP-Complete.

Checking collinearity of exactly 3 points is NOT NP-Complete as it is solvable in O(1). NP-Completeness applies to the general version: given n points, determine whether any 3 are collinear, which is what the following proof addresses.

Thus, it can be verified that the collinearity problem (for n points) is NP-Complete using the following propositions:

Collinearity Problem is in NP:

If any problem is in NP, then given a 'certificate', which is a solution to the problem and an instance of the problem (a collection of a collection of n points) we will be able to identify(whether the solution is correct or not) certificate in polynomial time. This can be done by checking:

Collinearity problem is NP-Hard:

In order to prove the Collinearity problem is NP-Hard, deduce a reduction from a known NP-Hard problem, that is, 3-Sum to collinearity problem. For each x in the 3-Sum instance, map from x to (x, x3). Now, from 3 Sum instances (x, y, z) we have ((x, x3), (y, y3), (z, z3)). 
The following propositions hold:
Let set S has collinear points (x, x3), (y, y3), (z, z3)
Now,

=> => => => =>

Therefore, (x, y, z) are collinear points. These equations are interchangeable.
Therefore, the Collinearity Problem is NP-Complete.

Comment