Let argument of function Func is k.
Case 1: If at least on of the array is sorted (say array1) then.
  For each number in array2, do
   1.  binary search  for (k - array1[i]) in array1
   2. if found
           return true.
       else
      return false
case 2: Arrays are not sorted then
    1. Sort one array and apply algo for case 1.

Time complexity will be  sizeof(unsortedarray)log (sizeofsortedarray).

Regards,
Shafi
On Fri, Jul 23, 2010 at 12:01 AM, vijay <[email protected]> wrote:

> You have 2 arrays of integer. You have to write a function, which take
> an integer as input and returns bool. Example array 1 has {1,5,10}
> array 2 has {2,5,9}. Func(3) should return true, since 1 (from array
> 1) +2 (from array 2) =3 ( i.e summation of 2 numbers (1 from each
> array) is equal to 3). Func(13) should return false
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Regards,
Shafi Ahmad

The difficult we do immediately, the impossible takes a little longer....US
Army

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

Reply via email to