UGC-NET Dec 2012 · Asymptotic Analysis & Recurrences
MCQ · 2 marks · Problem PROG-DIVC-0009
Suppose there are \(\lceil \log n\rceil\) sorted lists of \(\lfloor n/\log n\rfloor\) elements each. The time complexity of producing a sorted list of all these elements is (Hint: use a heap data structure)
Show the worked solution\[\boxed{k\text{-way merge with a min-heap of size } k:\ O(N\log k)}\]Put the first element of each of the \(k=\lceil\log n\rceil\) lists in a min-heap. Repeatedly extract the minimum and insert the next element from the same list. Each of the \(N\approx n\) elements costs one extract and one insert, \(O(\log k)\) each.\[T=O(n\log k)=O(n\log\log n).\]This is also the lower bound for merging \(k\) sorted lists, so the time is not \(\Omega(n\log n)\): (B), (C) and (D) are false.(The UGC-NET copy misprinted the list size as "n log n elements each"; the original GATE 2005 question has \(n/\log n\).)Answer: A
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com