If a function has a O(N) complexity and it is called in an if statement is it still O(1)?
For example:
f(x);
if (f2(x))
f3(x);
where f(x) is O(N) f2(x) is O(N) and f3(x) is O(Nlog2N).
So would the overall complexity of this fragment be O(Nlog2N) in the worst case where the conditional is true?
Yes. It is the worst case scenario.
In one case it is o(n) and other case o(N lg n).
So since we re interested in worst case we say it’s latter.