Re: [algogeeks] Re: aai + bj + ck =0

2009-11-02 Thread daizi sheng
ck will be changed every time for your example there will be at most N ck, and so the inner loop will be executed for at most O(N) time. when there is no available ck, the inner loop will exit On Tue, Nov 3, 2009 at 12:45 PM, dinesh bansal wrote: > I think this algorithm is O(N^3) because in a

Re: [algogeeks] Re: aai + bj + ck =0

2009-11-02 Thread dinesh bansal
I think this algorithm is O(N^3) because in a worst case when condition "if(ai + bj + ck > 0)" fail for all the elements in C, the inner loop will run for N^3 times since we have not incremented j yet. lets take a very rough example , A = {1,2,3,4,5}, B = {2,3,4,5,6}, C = {7,6,5,4,3}, the conditi