Suppose there are multiple functions with certain big o notations, anything O(N), O(N^2), etc.
If you have a code fragment such as.
f1(x);
f2(x);
f3(x);
Are all the big O notations added together or multiplied? Any explanation as to why either would be correct – addition or multiplication?
Neither. You would take the maximum.
Calling the larger piece of code
g… If for example O(f2) >= O(f1) and O(f2) >= O(f3), then the complexity ofgis <= 3 * O(f2) = O(f2).