find a largest subset of collinear points.
int main() cout << find-maximal-collinear-subset( read_points(std::cin))
read_points()
and
find-maximal-collinear-subset()
?
find-maximal-collinear-subset()
read_points()
find-maximal-collinear-subset()
.
find-maximal-collinear-subset(pts) lcs = { } for each subset ss in pts if collinear(ss) and #ss > #lcs lcs = ss return lcs
find-maximal-collinear-subset(pts) lcs = { } for each subset ss in pts if collinear(ss) and #ss > #lcs lcs = ss return lcs
collinear()
is a problem, as is generating subsets.
collinear()
is a solved math problem.
generate-subsets(s) if s ≠ {} for each e in s s' = s - {e} generate-subsets(s')
find-maximal-collinear-subset()
used a for loop.
find-maximal-collinear-subset(pts, lcs) if collinear(pts) lcs = pts else for each e in pts pts' = pts - {e} generate-subsets(pts', lcs)
find maximal collinear subset(points) max points = { } for p1 in points order points by increasing angle scan for similar angles similar angles mean collinear points remember the biggest set return max points