Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE CS 2019 | Question 46

  • Last Updated : 18 Feb, 2019

There are n unsorted arrays: A1, A2, ….,An. Assume that n is odd. Each of A1, A2, …., An contains n distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1, A2, ….,An is ________ .

(A) Ο(n log n)
(B) Ο(n2)
(C) Ο(n)
(D) Ω(n2log n)

Answer: (B)

Explanation: Since given arrays are not sorted, so the time complexity to find median is O(n) in an unsorted array. You need to apply this apgorithm n time to find all medians and again once to find median of all these medians, so total time complexity is,

= O(n)*O(n) + O(n)
= O(n2) + O(n)
≈ O(n2) 

So, option (B) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :