My approach:

let's say we have two sorted arrays.
array1= x1, x2 x3
array2 = y1, y2, y3
array3= z1, z2,z3
all three arrays are sorted.

1. sort x1,y1,z1 using heap sort.
2. do this for rest of the elements of the array to create a final sorted
array in O(nlogk)


On Sat, Jun 5, 2010 at 8:45 PM, Anand <[email protected]> wrote:

> Add all the arrays to the heap comparision being only from the first
> element.
>
> "Can you elaborate this statement Could not understand."
>
>
> On Sat, Jun 5, 2010 at 8:20 PM, Rohit Saraf 
> <[email protected]>wrote:
>
>> Did not understand what u said but it is extremely straight forward
>>
>> Add all the arrays to the heap comparision being only from the first
>> element. Now remove the root, take the first element of root array and
>> reinsert the rest of the array. Just keep doin this.
>>
>> To save space you might want to avoid adding the whole array and just
>> add some reqd pointers. But the algo remains the same.
>>
>> --
>> --------------------------------------------------
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>> --
>> 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.

Reply via email to