in Algorithms reopened by
592 views
0 votes
0 votes

An algorithm is made up pf two modules $M1$ and $M2.$ If order of $M1$ is $f(n)$ and $M2$ is $g(n)$ then the order of algorithm is

  1. $max(f(n),g(n))$
  2. $min(f(n),g(n))$
  3. $f(n) + g(n)$
  4. $f(n) \times g(n)$
in Algorithms reopened by
592 views

3 Comments

option A) max(f(n),g(n))
0
0
COMPLEXITY   BETTER

TO TAKE WROST CASE  SO WE GO WITH OPTION  A
0
0

1 Answer

2 votes
2 votes
option A will be correct

In order to find the order of the algorithm, there are three possible cases with f(n) and g(n)
Case-1 : if 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 can ignore this one .
Case-2 : 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 can ignore this one.
Case-3: f(n) = g(n)
Time Complexity can be either O(g(n)) or O(f(n)) (which is equal asymptotically). So the order of the algorithm is max(f(n), g(n))
Answer:

Related questions