[algogeeks] How to find median of 2 sorted arrays of different length

2011-09-01 Thread Ankur Garg
Can anybody explain logic ?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@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.



Re: [algogeeks] How to find median of 2 sorted arrays of different length

2011-09-01 Thread Dheeraj Sharma
let the total sum of the lengths of the two array is 'Len'
Median is Len/2 (if the two arrays are combined and sorted)

int count=0,i=0,j=0;

while(count(Len/2))
{

if(arr1[i]arr2[j])
i++;
else
j++;
count++;
}

if(arr1[i]arr2[j])
arr1[i]=median
else
arr2[j]=median

On Thu, Sep 1, 2011 at 9:01 PM, Ankur Garg ankurga...@gmail.com wrote:

 Can anybody explain logic ?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@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.




-- 
*Dheeraj Sharma*
Comp Engg.
NIT Kurukshetra
+91 8950264227

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@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.