UGC-NET Jun 2014 · Asymptotic Analysis & Recurrences
MCQ · 2 marks · Problem PROG-DIVC-0008
An algorithm is made up of $2$ modules $M_{1}$ and $M_{2}$ . If time complexity of modules $M_{1}$ and $M_{2}$ are $h(n)$ and $g(n)$ respectively, the time complexity of the algorithm is
Show the worked solution\[\boxed{O(h(n))+O(g(n))=O\big(\max(h(n),g(n))\big)}\]The modules run one after the other, so the total time is \(h(n)+g(n)\). Since\[\max(h,g)\le h+g\le 2\max(h,g),\]the sum has the same order as the larger term (rule of sums). The complexity is therefore governed by \(\max(h(n),g(n))\).(A) The minimum ignores the slower module — incorrect.(D) A product would describe nested execution, not sequential modules — incorrect.Answer: B
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com