copy the array(A) in a different array(B) to store the index info.(space
O(n))
sort(A)
take each pair's sum ( complexity  O(n^2) ) and with that do a binary search
for the 3rd element needed.(O(log(n))).

Check for the indices in B.

i believe it can be done in better time somehow.

On Mon, May 3, 2010 at 6:48 PM, jalaj jaiswal <jalaj.jaiswa...@gmail.com>wrote:

>
> given an array(unsorted) may contain negative numbers too
> find the index of three numbers whose sum is closest to zero  in  O(N2 log
> N) time and O(N) space.
>
> P.S -3 is more close to zero then -6 (number line ...)
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> IIIT ALLAHABAD
>
> --
> 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