'Is the following statement true? If g = O(f) and h = O(f) then g = O(h) for all f,g,h

Does that statement follow Big O transitivity? I am new to Big O notation and Time Complexity so I am struggling with the basics. Any help would be greatly appreciated!



Solution 1:[1]

Think of the counterexample:

f(n) = n3

g(n) = n2

h(n) = n.

Indeed, g = O(f) and h = O(f). But is g = O(h)?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Berthur