I/P:

A:               1, 3,55,66,77,_,_,_
B:                5,9,20

Have 3 variables pointing at
m = last index of A
n = last index  of B
p = last index of A+B

A[m]>A[n]
  -> A[p] = A[m]; m--; p--

else
 -> A[p]=A[n]; n--; p--


run this till m and n becomes 0

liner time complexity


Mohit


On Wed, Dec 29, 2010 at 2:21 PM, monty 1987 <[email protected]> wrote:

> Hi Guys ,
>                  We have an array of size m+n in which m elements are
> present in sorted order and other array of size n again in sorted order . We
> want both of them to be sorted and present in first array.No third array is
> supposed to be given.
>
>  like
>
>                1, 3,55,66,77,_,_,_
>                 5,9,20
>
> Answer would be:
>                 1,3,5,9, 20,55 66 ,77
>
> --
> 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.
>

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