Technically the complexity is O(1)
because 100
is a constant and thus the number of operations is always the same. If the author assumed that 100
is a parameter and can be some variable, i.e.
int n = 100; //or read it somewhere
for (int i = 10; i < n; ++i) {
....
}
then the complexity is O(n^3)
. The first cycle body is executed n - 10
times which is O(n)
, the second cycle's body is executed from n - 10
times to once, which is again O(n)
, and the same can be stated for the innermost cycle, thus giving us O(n^3)
.
Article useful for understanding the big O notation: Big O notation