Re: [algogeeks] question to code

2011-08-22 Thread tanuj chawla
@sanjay - shouldnt we use count instead of second k. and when count
becomes size/2,we get the element becouse we dont know the array in which
that element resides
correct me if m wrong??

-- 
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] question to code

2011-08-22 Thread Sanjay Rajpal
in the solution I proposed, k is doing the job of count. I think u should
look at it again.


Sanju
:)



On Mon, Aug 22, 2011 at 1:42 AM, tanuj chawla houndhun...@gmail.com wrote:

 @sanjay - shouldnt we use count instead of second k. and when count
 becomes size/2,we get the element becouse we dont know the array in which
 that element resides
 correct me if m wrong??



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


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



[algogeeks] question to code

2011-08-21 Thread vaibhav shukla
given three sorted arrays not necessary of same length (length is given)
we have to determine the middle element such that  the element will be the
middle one of the such an array which will be formed if all three given
arrays are merged in
sorted order.
input  :- arr1 :  1,3,5,7
arr2 :   6,9,12,15,18
arr3 :  2,4,14,20
output : 7 , as if we merge the arrays in sorted order then 7 will be the
middle element of that merged array.
note : if merged array is of even length then there will be two middle
element.

ALSO YOU CANNOT USE EXTRA MEMORY.


-- 
  best wishes!!
Vaibhav

-- 
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] question to code

2011-08-21 Thread Puneet Chawla
Here by just applying merge on these array as they are sorted and calculate
the middle element..Am i rt..???

On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 given three sorted arrays not necessary of same length (length is given)
 we have to determine the middle element such that  the element will be the
 middle one of the such an array which will be formed if all three given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be the
 middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




-- 
With regards
  
Puneet Chawla
Computer Engineering Student
NIT Kurukshetra

-- 
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] question to code

2011-08-21 Thread Sanjay Rajpal
Take three pointers to the beginning of each array say i,j,k.

Now let sum = len a +len b + len c.
k=0

now start from the beginning, compare elements at indexes i,j,k.
which ever is smaller, increment that index and k, continue till k becomes
sum/2.

when k becomes sum/2, this element will be middle element of the merged
array.

I think it could also be done in O(log m + log n + log p), where m, n,p are
lengths of the arrays.

Correct me if m wrong :)
Sanju
:)



On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla
puneetchawla...@gmail.comwrote:

 Here by just applying merge on these array as they are sorted and calculate
 the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.comwrote:

 given three sorted arrays not necessary of same length (length is given)
 we have to determine the middle element such that  the element will be the
 middle one of the such an array which will be formed if all three given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be the
 middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


-- 
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] question to code

2011-08-21 Thread vaibhav shukla
@puneet : but u cant use extra memory

On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k becomes
 sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p are
 lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla puneetchawla...@gmail.com
  wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla vaibhav200...@gmail.com
  wrote:

 given three sorted arrays not necessary of same length (length is given)
 we have to determine the middle element such that  the element will be
 the middle one of the such an array which will be formed if all three given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be the
 middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




-- 
  best wishes!!
Vaibhav
  MCA

-- 
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] question to code

2011-08-21 Thread Puneet Chawla
ohh sryy i didn't read tht

On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 @puneet : but u cant use extra memory


 On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k becomes
 sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p
 are lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla 
 puneetchawla...@gmail.com wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 given three sorted arrays not necessary of same length (length is given)
 we have to determine the middle element such that  the element will be
 the middle one of the such an array which will be formed if all three given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be
 the middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




 --
   best wishes!!
 Vaibhav
   MCA


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




-- 
With regards
  
Puneet Chawla
Computer Engineering Student
NIT Kurukshetra

-- 
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] question to code

2011-08-21 Thread vaibhav shukla
@sanjay : yes this is one approach . just doing this and keeping track of
the smaller element and wen k is sum/2, the minimum element of the middle on

true. but any other approach apart from this and wat if the total length is
even, i.e u have to give two middle elements then

On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 @puneet : but u cant use extra memory


 On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k becomes
 sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p
 are lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla 
 puneetchawla...@gmail.com wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 given three sorted arrays not necessary of same length (length is given)
 we have to determine the middle element such that  the element will be
 the middle one of the such an array which will be formed if all three given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be
 the middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




 --
   best wishes!!
 Vaibhav
   MCA




-- 
  best wishes!!
Vaibhav
  MCA

-- 
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] question to code

2011-08-21 Thread Puneet Chawla
@sanjay why you have compared k with sum/2 is it a general solution..???

On Sun, Aug 21, 2011 at 11:11 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 @sanjay : yes this is one approach . just doing this and keeping track of
 the smaller element and wen k is sum/2, the minimum element of the middle on

 true. but any other approach apart from this and wat if the total length is
 even, i.e u have to give two middle elements then


 On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla 
 vaibhav200...@gmail.comwrote:

 @puneet : but u cant use extra memory


 On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k
 becomes sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p
 are lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla 
 puneetchawla...@gmail.com wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 given three sorted arrays not necessary of same length (length is
 given)
 we have to determine the middle element such that  the element will be
 the middle one of the such an array which will be formed if all three 
 given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be
 the middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




 --
   best wishes!!
 Vaibhav
   MCA




 --
   best wishes!!
 Vaibhav
   MCA

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




-- 
With regards
  
Puneet Chawla
Computer Engineering Student
NIT Kurukshetra

-- 
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] question to code

2011-08-21 Thread Sanjay Rajpal
see sum is total no.of elements in three arrays.

the question is middle element in the merged array.

so the middle element would be at index sum/2.
Sanju
:)



On Sun, Aug 21, 2011 at 10:46 AM, Puneet Chawla
puneetchawla...@gmail.comwrote:

 @sanjay why you have compared k with sum/2 is it a general solution..???


 On Sun, Aug 21, 2011 at 11:11 PM, vaibhav shukla 
 vaibhav200...@gmail.comwrote:

 @sanjay : yes this is one approach . just doing this and keeping track of
 the smaller element and wen k is sum/2, the minimum element of the middle on


 true. but any other approach apart from this and wat if the total length
 is even, i.e u have to give two middle elements then


 On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla vaibhav200...@gmail.com
  wrote:

 @puneet : but u cant use extra memory


 On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.comwrote:

  Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k
 becomes sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p
 are lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla 
 puneetchawla...@gmail.com wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 given three sorted arrays not necessary of same length (length is
 given)
 we have to determine the middle element such that  the element will be
 the middle one of the such an array which will be formed if all three 
 given
 arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be
 the middle element of that merged array.
 note : if merged array is of even length then there will be two middle
 element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




 --
   best wishes!!
 Vaibhav
   MCA




 --
   best wishes!!
 Vaibhav
   MCA

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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


-- 
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] question to code

2011-08-21 Thread Sanjay Rajpal
http://stackoverflow.com/questions/6182488/median-of-5-sorted-arrays this
link will help m damn sure.
Sanju
:)



On Sun, Aug 21, 2011 at 10:48 AM, Sanjay Rajpal srn...@gmail.com wrote:

  see sum is total no.of elements in three arrays.

 the question is middle element in the merged array.

 so the middle element would be at index sum/2.
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:46 AM, Puneet Chawla puneetchawla...@gmail.com
  wrote:

 @sanjay why you have compared k with sum/2 is it a general solution..???


 On Sun, Aug 21, 2011 at 11:11 PM, vaibhav shukla vaibhav200...@gmail.com
  wrote:

 @sanjay : yes this is one approach . just doing this and keeping track of
 the smaller element and wen k is sum/2, the minimum element of the middle on


 true. but any other approach apart from this and wat if the total length
 is even, i.e u have to give two middle elements then


 On Sun, Aug 21, 2011 at 11:09 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 @puneet : but u cant use extra memory


 On Sun, Aug 21, 2011 at 11:08 PM, Sanjay Rajpal srn...@gmail.comwrote:

  Take three pointers to the beginning of each array say i,j,k.

 Now let sum = len a +len b + len c.
 k=0

 now start from the beginning, compare elements at indexes i,j,k.
 which ever is smaller, increment that index and k, continue till k
 becomes sum/2.

 when k becomes sum/2, this element will be middle element of the merged
 array.

 I think it could also be done in O(log m + log n + log p), where m, n,p
 are lengths of the arrays.

 Correct me if m wrong :)
 Sanju
 :)



 On Sun, Aug 21, 2011 at 10:34 AM, Puneet Chawla 
 puneetchawla...@gmail.com wrote:

 Here by just applying merge on these array as they are sorted and
 calculate the middle element..Am i rt..???


 On Sun, Aug 21, 2011 at 10:59 PM, vaibhav shukla 
 vaibhav200...@gmail.com wrote:

 given three sorted arrays not necessary of same length (length is
 given)
 we have to determine the middle element such that  the element will
 be the middle one of the such an array which will be formed if all three
 given arrays are merged in
 sorted order.
 input  :- arr1 :  1,3,5,7
 arr2 :   6,9,12,15,18
 arr3 :  2,4,14,20
 output : 7 , as if we merge the arrays in sorted order then 7 will be
 the middle element of that merged array.
 note : if merged array is of even length then there will be two
 middle element.

 ALSO YOU CANNOT USE EXTRA MEMORY.


 --
   best wishes!!
 Vaibhav


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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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


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




 --
   best wishes!!
 Vaibhav
   MCA




 --
   best wishes!!
 Vaibhav
   MCA

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




 --
 With regards
   
 Puneet Chawla
 Computer Engineering Student
 NIT Kurukshetra

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




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