4,862 views
1 votes
1 votes
Consider the following 2 functions:
f(n)= n3, if 0 ≤ n < 10,000
= n2, otherwise
g(n)= n, if 0 ≤ n < 100
= n2 + 5n, otherwise

 

Which of the following option is correct?
(a) f(n) is O(n3) (b) g(n) is O(n3)
(c) O(f(n)) is same as O(g(n)) (d) g(n) is O(1)

2 Answers

0 votes
0 votes
At asymptotical(tend to infinite values) ,let here be for n beyond 10000,(as it is the max number in ques) ,

f(n) = n2 = O(n2)  and g(n) = n2+5n = O(n2)

and n2 can be written as O(n3) hence both opt A and B are correct , still opt C wins the race as it is the EXACT answer as both fn and gn are same in Big-oh.
Answer:

Related questions

0 votes
0 votes
2 answers
1
Pranav Madhani asked May 25, 2017
8,457 views
Which of the following is not O(n^2)?(a) (15^10) * n + 12099 (b) n^1.98(c) n^3 / (sqrt(n)) (d) (2^20) * n
0 votes
0 votes
0 answers
3