merging datastreams using O(1) RAM
How can I merge k sorted data streams using O(1) RAM ? How should I define
the data stream object and its related functions/operations ?
My solution : Well I thought of using array lists as the data stream
object. I planned to find the minimum value of the 0th index of the k
array lists.The minimum value should be removed from that array list and
should be put it in the output array list. This process should be repeated
until all the k array lists have become null.But I guess this would take
O(k*length of each array list). Any ideas how to do it in O(1) ?
No comments:
Post a Comment