for i := 1 to n
for j : = 1 to i
for k := 1 to 18
BEEP
next k
next j
next i
Which of the following are true?
f(n) is O(n^3)
f(n) is Θ (n^2)
f(n) is Ω (n^3)
for i := 1 to n
for j : = 1 to i
for k := 1 to 18
BEEP
next k
next j
next i
Which of the following are true?
f(n) is O(n^3)
f(n) is Θ (n^2)
f(n) is Ω (n^3)
If you analize the three loops, from external one to the nested one, the following is each one time complexity (Big O):
O(n) * O(n) * O(1) -> O(n^2)