n^2 algo should be obvious, e.g.

1. sort them
2. enumerate ai, bj both in ascending order, then you just need to
test ck in descending order instead of enumerating it

or you can even make a hash table for C array and then enumerate the
first two arrays.


On Fri, Oct 30, 2009 at 7:53 PM, ankur aggarwal
<[email protected]> wrote:
> Given 3 randomly filled array of size N ( say A<a1,a2..aN> , B<b1,b2…bN> and
> C<c1,c2..cN> ).give Algorithm to verify if there exists a triplet such that
> ai + bj + ck =0 where
> 0<I,j,k<=N Time complexity of Your algorithm should be O(NlogN) and state
> space complexity of
> you’re algorithm .O(N^2) algorithm will get partial credit.
> >
>

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

Reply via email to