The operation in line 4 is dominant and will be executed n times. The complexity is described
in Big-O notation: in this case O(n) — linear complexity.
The complexity specifies the order of magnitude within which the program will perform
its operations. More precisely, in the case of O(n), the program may perform c · n operations,
where c is a constant; however, it may not perform n2 operations, since this involves
a di!erent order of magnitude of data. In other words, when calculating the complexity we
omit constants: i.e. regardless of whether the loop is executed 20 · n times or n
5 times, we still
have a complexity of O(n), even though the running time of the program may vary. When
analyzing the complexity we must look for specific, worst-case examples of data that the
program will take a long time to process.