let arr1[5]={6,7,8,9,10}
arr2[5]={1,2,3,4,8}
your codes gives answer=5
which is not correct...
the correct answer should be=6.5
but since you are returning integer and answer would be=6
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Given 2 set of arrays of size N(sorted +ve integers ) find the median of the
resultent array of size 2N.
(dont even think of sorting the two arrays in a third array , though u can
sort them. Try something better than order N ..order LogN )
--
Regards
Chunky Garg
--
You received this message
int median(int arr1[],int arr2[],int N)
{
if(N==2)
{
return ((max(arr1[0],arr1[1])+ min(arr2[0],arr2[1]))/2);
}
int mid=N/2;
if(arr1[mid]==arr2[mid])
return arr1[mid];
if(arr1[mid]arr2[mid])
return median(arr1,arr2+N/2,N-N/2);
** Make NECESSARY assumptions.
.Kingdom of *Maplewood* is a beautiful country comprising of a lot of small
islands of different areas. All the islands are in a straight row. King *
Rosewood* is getting old and has decided to divide the islands among his two
sons - *Eric* and *Finn*. Luckily,