edited by
5,366 views
0 votes
0 votes

An algorithm is made up of $2$ modules $M_{1}$ and $M_{2}.$ If order of $M_{1}$ is $f(n)$ and $M_{2}$ is $g(n)$ then the order of the algorithm is$:$

  1. $\text{max (f (n) ,g (n))}$
  2. $\text{min (f (n) ,g (n))}$
  3. $\text{f (n) + g (n)}$
  4. $\text{f (n) $\times$ g (n )}$
edited by

1 Answer

1 votes
1 votes

Option A.

Three cases are possible with f(n) and g(n),

Case (i) : f(n) $>$ g(n)

In this case we take O(f(n)) the complexity of the algorithm as g(n) is a lower order term, we drop it.

Case (ii) : f(n) $<$ g(n)

In this case we take O(g(n)) the complexity of the algorithm as f(n) is a lower order term, we drop it.

Case (iii) : f(n) $=$ g(n)

Time Complexity can be either O(g(n)) or O(f(n)) (which is equal asympotically).

Hence, max(f(n), g(n))

Answer:

Related questions