suppose after caliculating slopes for ist point we formed set points(n=9)
whose slopes are eequal are
{1,2,3,4},{1,5,6,7,9},{1,}.
now for second point we will definitely get 1 set{1,2,3,4}and some other and
we have to eliminate this set
it takes some more timeOn Wed, Oct 13, 2010 at 5:52 PM, Dave <[email protected]> wrote: > @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 <[email protected]> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
