@Anoop: It can be done in O(n^2):

Sort arrays B and C
For i = 1 to n Do
    j = 1
    k = n
    While( j <= n and k >= 1)
        If( A(i) + B(j) + C(k) < 0 ) Then j = j + 1
        Else if( A(i) + B(j) + C(k) > 0 ) Then k = k - 1
        Else Return TRUE
    End While
Return FALSE

The While loop is iterated at most 2N times for each i.

Dave

On Jan 11, 4:02 am, anoop chaurasiya <anoopchaurasi...@gmail.com>
wrote:
> does any better solution exists than O(N^2logN)??
>
> On Tue, Jan 11, 2011 at 2:56 AM, juver++ <avpostni...@gmail.com> wrote:
> > There is no need to sort first two arrays.
>
> > --
> > 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.
>
> --
> Anoop Chaurasiya
> CSE (2008-2012)
> NIT DGP

-- 
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