//don't know this is completely correct or not

1.find sum of elements of both arrays a[] and b[]...from 0 to n-1

2.check whichever is smaller sum_a or sum_b...say sum_a is smaller

3.generate a random number i=random(sum_a)... generates random number
between o to (sum_a)-1
        //random generator will generate number between 0 to (sum_a)-1 with
equal probability ...
        //so every number will come in generation...but for more preciseness
generate this i = 4 times the(sum_a)-1

4.check if this i is present in array a[] and b[] as sum
        SUM(a[1 .. n], i):
        if i = 0
        return TRUE
        else if i < 0 || n = 0
        return FALSE
        else
        return ((SUM(a[2 .. n], i) || (SUM(a[2 .. n], i-a[1]))


..
or we can also search for every possible sum in array a[] and then search if
this sum is present in array b[]

..




On Tue, Sep 13, 2011 at 12:12 AM, parag khanna <[email protected]>wrote:

> .eg:[5 6 2 8 1] or [4 7 9 2 4]...such arrays are given, you have to find
> possible pairs  where sum of numbers in both arrays of a pair is equal....eg
> for the first case it will be [5 6] and [2 8 1]
>
> write a program to implement this
>
>
>
>
> --
> Parag Khanna
> B.tech Final Year
> NIT,Kurukshetra
>
>  --
> 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.
>

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