u dont want to consider all (i,j) pairs..
if A and B are sorted, i think A[i]+B[i] shud give the desired array.

On 9/12/06, philosup < [EMAIL PROTECTED]> wrote:
add A[i] and B[i] - O(n)
this is right but..
 
A[i] + B[j] ( 0<=i, j<=n) - O(n^2)

 
2006/9/12, Arun <[EMAIL PROTECTED]>:
sort A and B seperately -> O(nlgn)..
add A[i]and B[i]  - O(n)
so, O(nlgn) .
linear time maybe possible.



On 8/25/06, Amal < [EMAIL PROTECTED]> wrote:

There are 2 arrays say array A and array B given whose size is 'n'. Now i have to find the first n maximum values of a[i]+b[j] .  I would like to know O(n) or O(n logn ) solutions if some exist.

Amal.



 







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