@daizi i think this will not be n^2. check it again ..
On Sun, Nov 1, 2009 at 1:09 PM, daizi sheng <[email protected]> wrote: > with all arrays sorted firstly, if you enumerate ai, bj in ascedning order, > ck will be sure in descending order. > > foreach(ai in A) > ck = largest element in C > foreach(bj in B) > AGAIN: > if(ai + bj + ck == 0) algorithm over > if(ai + bj + ck > 0) ck change to its neighbor in C and goto AGAIN > if(ai + bj + ck < 0) continue checking next bj > > > On Sun, Nov 1, 2009 at 3:10 PM, anilkumarmyla <[email protected]> > wrote: > > No matter whatever i could think of, I am unable to do better than N^3 > > > > @daizi sheng > > I don't get your algorithm > > "2. enumerate ai, bj both in ascending order," > > Will that really help ? In what way ? > > > > -- > > > > 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]. > > 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]. > 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]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
