Computer Algorithms II Lecture Notes

9 October 2007 • Maximum Colinear Points


S is a set of integer points on a grid.

Lines through S may intersect points in S.

Find a largest subset of S through which a line can pass.

A point in S is either in a largest subset or not.

A point not in the subset can be ignored.

A point in the subset has a line passing through it. But which line?

Look at all lines through P.

For each line, count the other points it passes through.

Find the largest number of points intersected by any line through p.

Three points are colinear if any two pair have the same slope.

max-intersects() doesn't return the answer if p isn't in a subset.

Run max-intersects() over every point in S.

All points colinear with p have the same slope.

Find all slopes with p; the most frequent one is the answer.

A slope is a relatively-prime pair of numbers.

Order slopes as a fraction, or lexicographically.

Once grouped, find the most frequently occurring slope.

intersects() is O(n); max_intersects() is O(n2).

max-intersects() is O(n3).

get-slopes() is O(n).

max-group-size() is O(n).

max-intersects() is O(n log n).

max-intersects() is O(n2 log n).

So What?

Summary


This page last modified on 18 October 2007.

This work's CC license.