What would the big O worst case be if it calls a function that is of an independent size parameter?

What would be the worst time complexity big O notation for the following pseudocode? The function call to the algorithm is an O(n)) I'm very new to big O notation so I'm unsure of an answer. I know that if the algorithm function called is just O(1) then its big O of O(log(n)) but what happens to the big O notation if the algorithm called is of O(n) and also, what would happen to it if it was O(m) (an independent size parameter)?

My thoughts were that it wouldn't have an effect on O(log(n)) the big O for the O(n) algorithm, but I'm unsure if that is even close to correct, I'm also unsure on the O(m) as well.

Any input/help is appreciated, I'm trying to grasp the concept of big O notation for worst time complexity which I just learning. Thanks!

1
2
3
4
5
  i ← 1
while(i<n)
    doSomething(...)
    i ← i * 2
done
Last edited on
It doesn't matter if the code is in a function or not. You could put the code for doSomething(...) directly inside the loop and it will not change the big O of your algorithm (as long as it still do the same thing).
It looks to me like either O(n log n) or O(m log n), depending on what you pass to doSomething().
Topic archived. No new replies allowed.