Big-O notation Question

PeterRobinson44

New member
Joined
May 14, 2020
Messages
12
Using the provided pseudo-code, find the worst-case performance in Big-O notation.

Pretty much Big-O is finding the largest in the question. I go in this order from lowest to highest. 100, log10^n, 10n, n x log10n, n^2, n^10, 10^n

1) procedure SOMEPROCEDURE1
for i = 1 to n
if (sum == 0)

I believe it's (n^2)

2) procedure SOMEPROCEDURE2
for i = 1 to n
if (sum == 1)

I believe it's (n^2) too
 
It doesn't seem like there's enough in either loop to judge; something has to follow each if statement, and that might make a difference!

Can you explain why you think they are O(n^2)? From the little I see, I'd call them O(n).

If you didn't quote everything you were given, please do so.
 
Top