Consider the case: f(n) = O(g(n)). Then, following two statements are ...
if f(n) = n and g(n) = 2n. then f(n) = O(g(n))
here, 2^n = O(2^(2n)) = O(4^n), but not vice versa.
Hence, I is true. II is false. --------------
Now, if f(n) = 2n and g(n) = n then also f(n) = O(g(n)) because we can ignore constant but, 2^(2n) != O(2^n),
hence I is false, but II is true.
In both of the above cases, f(n) = O(g(n)).
But both the cases are counter of each other. Hence both I and II are wrong.
View all questions of this test
Consider the case: f(n) = O(g(n)). Then, following two statements are ...
Statement I: 2f(n) = O(2g(n))
To determine the validity of this statement, we need to understand what it means for a function to be in big O notation. When we say that f(n) = O(g(n)), it means that there exists a positive constant c and a value of n0 such that for all values of n greater than or equal to n0, f(n) is bounded above by c * g(n).
Now, let's consider the statement 2f(n) = O(2g(n)). This statement is essentially saying that if we double the input size and double the function values, the growth rate of the functions remains the same. In other words, it is claiming that the function f(n) grows at the same rate as g(n).
To prove or disprove this statement, we can analyze the definition of big O notation. If f(n) = O(g(n)), then there exists a positive constant c and a value of n0 such that for all values of n greater than or equal to n0, f(n) is bounded above by c * g(n).
Now, let's consider 2f(n). If f(n) is bounded above by c * g(n), then 2f(n) will also be bounded above by 2c * g(n). This implies that 2f(n) = O(2g(n)) is true.
Statement II: 2g(n) = O(2f(n))
To determine the validity of this statement, we need to again analyze the definition of big O notation. If f(n) = O(g(n)), then there exists a positive constant c and a value of n0 such that for all values of n greater than or equal to n0, f(n) is bounded above by c * g(n).
Now, let's consider 2g(n). If f(n) is bounded above by c * g(n), then it is not necessarily true that 2g(n) will be bounded above by some constant times 2f(n). This is because the growth rate of f(n) and g(n) may not be the same.
Therefore, the statement 2g(n) = O(2f(n)) is not true in general and can be false.
Conclusion:
From the above analysis, we can conclude that:
- Statement I: 2f(n) = O(2g(n)) is true.
- Statement II: 2g(n) = O(2f(n)) is false.
Hence, the correct option is B) Both statements are false.