Saturday, December 28, 2024
Google search engine
HomeData Modelling & AIProof that Collinearity Problem is NP Complete

Proof that Collinearity Problem is NP Complete

Problem: Given 3 points a, b, c, the task is to check if these three points are collinear.

Explanation: An instance of the problem is an input specified to the problem. An instance of the collinearity problem is three points ((ax, ay), (bx, by), (cx, cy)). Since an NP-Complete is a problem which is 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 ≤ PC)

If the 2nd condition is only satisfied then the problem is called NP-Hard.
But it is not possible to reduce every NP problem into another NP problem to show its NP-Completeness all the time. That is why to show a problem is NP-complete, prove that the problem is in NP and any NP-Complete problem is reducible to that. Thus, it can be verified that the collinearity problem 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 three points a, b, c) we will be able to identify(whether the solution is correct or not) certificate in polynomial time. This can be done by checking:

\frac{b_{y}-a_{y}}{b_{x}-a_{x}}=\frac{c_{y}-b_{y}}{c_{x}-b_{x}}=0

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,

=> \frac{z^{3}-y^{3}}{z-y}=\frac{y^{3}-x^{3}}{y-x}=0 => y^{2}+xy+x^{2}=z^{2}+xz+x^{2} => -xz+xy=z^{2}-y^{2} => -x=z+y => x+y+z=0

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

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments