Can someone tell me what do you mean by median of 2 arrays ? Is it that the
sorted arrays are merged and finding the median of resulting one?

On Fri, Aug 13, 2010 at 1:32 AM, sachin <sachin_mi...@yahoo.co.in> wrote:

> If the ranges of the arrays are 1..n & 1..m, then we can solve it this
> way....
>
> if ((m+n)&1){
>  we can go with the method same as rahul patil's and in the condition
> we can use count<=(m+n)/2+1, the median will be stored in res.
> }
> else{
>  we can go with the method same as rahul patil's and in the condition
> we can use count<=(m+n)/2+1 and the median in this case will be the
> average of elements at count (m+n)/2 & at count (m+n)/2+1.So, we will
> have to store the last element in this case.
> }
>
> On Aug 11, 5:25 pm, rahul patil <rahul.deshmukhpa...@gmail.com> wrote:
> > is there any time complexity?
> >
> > the also can be like this
> >
> > char *res;
> > char *ptr1 =arr1;
> > char *ptr2 =arr2;
> > int count =0, n= len(arr1) ,m=len(arr2);
> > while(1){
> >          while(*ptr1 > *ptr2){
> >                   ptr2++;
> >                   count ++;
> >                   if( count == (n+m)/2 ){
> >                        res=ptr1;
> >                        break out of outer while loop;
> >                   }
> >          }
> >
> >          while(*ptr1 < *ptr2){
> >                   ptr1++;
> >                   count ++;
> >                   if( count == (n+m)/2 ){
> >                        res=ptr2;
> >                        break out of outer while loop;
> >                   }
> >          }
> >
> > }
> >
> > On Aug 6, 7:20 pm, Manjunath Manohar <manjunath.n...@gmail.com> wrote:
> >
> > > will this work in two sorted arrays of equal length..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to