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
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).