Question 5Asked in UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)

An algorithm is made up of 2 modules M₁ and M₂. If time complexity of modules M₁ and M₂ are h(n) and g(n) respectively, the time complexity of the algorithm is

  1. Amin (h(n), g(n))
  2. Bmax (h(n), g(n))
  3. Ch(n) + g(n)
  4. Dh(n) ∗ g(n)
Show answerHide answer

Correct answer: (B) max (h(n), g(n))

Explanation

When the two modules run one after the other, the total time is h(n) + g(n), which is O(max(h(n), g(n))) because the larger term dominates and lower-order terms are ignored. Hence the answer is (b).

From UGC NET Computer Science PYQ, June 2014 (Paper II & III, Selected Questions)

This is question 5 of UGC NET Computer Science PYQ, June 2014 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.