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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [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.
