option A) max(f(n),g(n))

Dark Mode

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

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