@Dave
I was wrong. It can't be done in O(n^2) time. The best we can do is sort
each row like you suggested in your other post. That will still be
O((n^2)logn).

Thanks,
- Ravindra

On Sun, Oct 24, 2010 at 7:06 PM, Meng Yan <mengyan.fu...@gmail.com> wrote:

> for the 3th step,
> for i=1 to n
>    for j=i+1 to n
>           for k=j+1 to n
>    compare A[i,j] and A[j,k]
> if A[i,j]==A[j,k]
> find i,j,k are collinear.
>
> so we should need O(n^3), is it right?
>
> On Sun, Oct 24, 2010 at 1:05 AM, ravindra patel 
> <ravindra.it...@gmail.com>wrote:
>
>> Can be done in O(n^2) time using the slope as people suggested above.
>>
>> 1- Sort the points in increasing order of x cord. O(nlogn)
>> 2- prepare a n*n matrix A where A[i,j] = slope( point(i), point(j) )  -
>> O(n^2) [Note that point i and j are sorted in increasing order of x]
>> 3- find a pair of A[i,j] and A[j,k] with same slope. [Can be done in
>> O(n^2)]
>>
>> Thanks,
>> - Ravindra
>>
>>
>> On Sun, Oct 24, 2010 at 10:11 AM, Dave <dave_and_da...@juno.com> wrote:
>>
>>> @Preetika: Then you have to look for duplicates in an array of n(n-1)/
>>> 2 real numbers. I think this takes the complexity above O(n^2).
>>>
>>> Dave
>>>
>>> On Oct 23, 10:54 pm, preetika tyagi <preetikaty...@gmail.com> wrote:
>>> > You have to scan every pair of points only once to get the value of 'm'
>>> and
>>> > 'a', so the time complexity would be O(n^2).
>>> >
>>> >
>>> >
>>> > On Sat, Oct 23, 2010 at 6:22 PM, Meng Yan <mengyan.fu...@gmail.com>
>>> wrote:
>>> > > there are (n*(n-1))/2pairs of points. I think if we use your method,
>>> the
>>> > > time complexity should be O(n^4).
>>> >
>>> > > Is it possible to put all points into k different domain and using
>>> > > T(n)=T(n/k)+f(n) to solve this problem?
>>> >
>>> > > On Sat, Oct 23, 2010 at 7:51 PM, preetika tyagi <
>>> preetikaty...@gmail.com>wrote:
>>> >
>>> > >> Is there any specific need to use recursion?
>>> >
>>> > >> One alternate is to find slope and constant (m and c) for every pair
>>> of
>>> > >> points and same value of m & c will specify the points on the same
>>> line.
>>> > >> Time complexity is O(n*n).
>>> >
>>> > >> On Sat, Oct 23, 2010 at 4:31 PM, Meng Yan <mengyan.fu...@gmail.com
>>> >wrote:
>>> >
>>> > >>> Given n point on the plane, find out whether any 3point on the same
>>> > >>> line.
>>> >
>>> > >>> How to use recursion to solve the problem? Could you help me find
>>> the
>>> > >>> algorithm and give the time complexity?
>>> >
>>> > >>> Bests,
>>> > >>> Claire
>>> >
>>> > >>>  --
>>> > >>> 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<algogeeks%2bunsubscr...@googlegroups.com>
>>> <algogeeks%2bunsubscr...@googlegroups­.com>
>>> > >>> .
>>> > >>> 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 algoge...@googlegroups.com.
>>> > >> To unsubscribe from this group, send email to
>>> > >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>> <algogeeks%2bunsubscr...@googlegroups­.com>
>>> > >> .
>>> > >> 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 algoge...@googlegroups.com.
>>> > > To unsubscribe from this group, send email to
>>> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>> <algogeeks%2bunsubscr...@googlegroups­.com>
>>> > > .
>>> > > For more options, visit this group at
>>> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>>> >
>>> > - Show quoted text -
>>>
>>> --
>>> 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<algogeeks%2bunsubscr...@googlegroups.com>
>>> .
>>> 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 algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> 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 algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> 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 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.

Reply via email to