@Mridul: For each point i, find the slope to every other point j and look for duplicates. Duplicates can be found by sorting the slopes and comparing adjacent values. Point i is collinear with the points in each set of duplicates. Keep track of the maximal set as you go.
For each i, you have n-1 slopes to calculate and sort and compare. Therefore, using a log n sort, the complexity of the algorithm is O(n^2 log n). Dave On Oct 13, 4:52 am, Mridul Malpani <malpanimri...@gmail.com> wrote: > There are n points in 2d space.we have their (x,y) co-ordinates. you > have to find the maximum set of points that are colinear? > I have used brute force, time =O(n^4). he wants a solution in O(n^3 or > n^2). -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.