Machine-translated by Google. Questions are authored in English.
Top

Discussion

Suppose there are \(\log_{n}\) sorted lists of n \(\log_{n}\) elements each. The time complexity of producing a sorted list of all these elements is (use heap data structure)

  • A.\(O(n \log \log_{n})\)
  • B.\(\theta(n \log_{n})\)
  • C.\(\Omega(n \log_{n})\)
  • D.\(\Omega(n^{3/2})\)

Answer: A

The key, option A, takes the lists to be log n in number and n divided by log n in length, so that the total number of elements is n. This is read from the key, since as printed the stem shows 'n log n' and not the quotient. With the heap method the merge keeps one element from each of the k = log n lists in a heap and removes the smallest each time. Each of the n steps costs \(O(\log k)\), so the time is \(O(n \log k) = O(n \log \log n)\). The other options, \(\theta(n \log n)\), \(\Omega(n \log n)\) and \(\Omega(n^{3/2})\), are larger than this bound, and a reviewer may wish to check the stem against the key.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.