You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
Templates used on this page:
Return to GATE2005 q39.
Suppose there are $logn$ sorted lists of $\frac{n}{logn}$ elements each. The time complexity of producing a sorted list of all these elements is: (Hint:Use a heap data structure)
(A) $O(nloglogn)$
(B) $ \Theta(nlogn)$
(C) $\Omega(nlogn)$
(D) $(n^{\frac{3}{2}})$
Since we have $logn$ lists we can make a min-heap of $logn$ elements by taking the first element from each of the $logn$ sorted lists. Now, we start deleting the min-element from the heap and put the next element from the sorted list from which that element came in the heap. (This identity can be done by making a structure of two values, one for the number and one for the origin sorted list and storing this structure in the heap). In this way each delete and the corresponding insert will take $O(loglogn)$ time as delete in heap is $O(1)$ and inserting an element on a heap of size $n$ is $O(nlogn)$ (here heap size is $logn$). Now, we have a total of $logn \times \frac{n}{logn} = n$ elements. So, total time will be $O(n loglogn)$.