The fact that it has one loop makes me think that O (n) is anyway.
It is right. Not because it makes one cycle, but because it is one cycle, which depends on the size of the array by a constant coefficient: a large O note ignores any constant factor. O(n) means that the only effect on the algorithm is based on the size of the array. Just because it actually takes half the time doesn't matter for large O.
In other words: if your algorithm takes time n+X , Xn , Xn + Y everything will go down to big-O O(n) .
Otherwise, if the size of the cycle changes differently than a constant, but as a logarithmic or exponential function n , for example, if size 100 and cycle 2 , size 1000 and loop 3 , size 10000 and cycle 4 . In this case, it will be, for example, O(log(n)) .
It would also be different if the cycle is size independent. If you always quote 100 times, regardless of the size of the loop, your algorithm will be O(1) (i.e., work in some constant time).
I was also wondering if the equation I came across to get there, somewhere on the football field, to be correct, was obtained.
Yes. In fact, if your equation ends up being n * C + Y , where C is some constant and Y is some other value, the result is O(n) , regardless of whether it sees more than 1 , or less than 1 .