4
$\begingroup$

I know this is a very standard question widely popular in the Internet and the Mathworld. I myself have solved the above problem is N^2 Log N avoiding floating arithmetic.However, can anyone give me a good resource/detailed explanation of how it can be solved in O(N^2) using point line duality concepts.

Sorry to create such a confusion regarding the statement. The text would be: "N different points with integer coordinates are given in a plane. You are to write a program that finds the maximum number of collinear points (they all belong to the same line)."

You may also refer to this site which is the problem I have solved using a N^2Log N approach.

  • 0
    Related to Dan's response: the maximum number of colinear points from a set of $N$ given points is obviously $N$. Let me suggest the rephrasing: "You are to find the largest number $M$ such that $M$ of the points from the original $N$ are colinear." You probably find this implicit.2011-02-04

3 Answers 3

1

By point-line duality, this is equivalent to the question 'given a configuration of $n$ lines in the plane, what is the maximum number of them which intersect at one point?'; since there are $O(n^2)$ pairwise intersection checks, it becomes a question of whether there's some bucketing/perfect hashing scheme that allows for finding a point in a dynamically-built list in $O(1)$ time. While I don't know of any specific bucketing schemes applicable to this problem, AFAIK it's very common to have $O(1)$ or at least $O(\alpha(n))$ approaches for this sort of thing ($\alpha(n)$ being the inverse-Ackermann function).

  • 0
    You could treat the verticals specially without too much trouble. Agree with the hash comment (I never claimed it was $\mathcal{O}(1)$):-)2011-02-03
1

Take a look at the two methods described in http://www.cs.princeton.edu/courses/archive/spring03/cs226/assignments/lines.html .

To find 4 or more collinear points given $N$ points, the brute-force method has a time complexity of $\mathcal{O}(N^4)$, but a better method does it in $\mathcal{O}(N^2 \log N)$.

-2

The maximum number of collinear points among N points in a plane is N (i.e., if they happen to be collinear.)

  • 0
    I might have answered the same, Ravi. Dan is pointing out that the usage of the word "maximum" is wrong.2011-02-04