0

I'm studying for an exam, and i've come across the following question:

Provide a precise (Θ notation) bound for the running time as a function of n for the following function

for i = 1 to n {
    j = i
    while j < n {
        j = j + 4
    }
}

I believe the answer would be O(n^2), although I'm certainly an amateur at the subject but m reasoning is the initial loop takes O(n) and the inner loop takes O(n/4) resulting in O(n^2/4). as O(n^2) is dominating it simplifies to O(n^2).

Any clarification would be appreciated.

reemq8
  • 9
  • 1
  • 4

1 Answers1

0

If you proceed using Sigma notation, and obtain T(n) equals something, then you get Big Theta.

If T(n) is less or equal, then it's Big O.

If T(n) is greater or equal, then it's Big Omega.

enter image description here