So I am learning how to calculate time complexities of algorithms from Introduction to Algorithms
by Cormen. The example given in the book is insertion sort:
1. for i from 2 to length[A]
2. value := A[i]
3. j := i-1
4. while j > 0 and A[j] > value
5. A[j+1] := A[j]
6. j := j-1
7. A[j+1] = value
Line 1.
executes n
times.
Line 4.
, according to the book, executes times.
So, as a general rule, is all inner loops' execution time represented by summation?