sort all elements :nlogn If the last 2 arrays are B and C, then sort elements of the form (bi+cj):O(n^2) time O(n^2) space [for the above step, smallest element in b1+c1,next element is smaller of (b1+c2) and(c1+b2), increase pointer accordingly. If at one step, the element under consideration is bi and cj, then the next smallest element is min(bi+c(j+1),b(i+1)+cj) ] for each element in A, see if corresponding element is there in [B+C] O(nlogn) If yes, then search for the corresponding two elements in array B and C O(nlogn)
total time O(n^2), space = O (n^2) -- 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?hl=en.
