To analyze an algorithm that you don’t want to take turns, you ask: "How long does this particular line take?" The reason is that each line is not executed as many times. For example, the innermost line is executed a whole group of times, compared to the first line, which is run only once.
, , . , , " sum++?", , , , . , , . i == 0, ( 0 0). i == 1 ( j == 1, j == 0. , k- k + 1 times. ,
1 + 2 + 3 + ... + N
N (N + 1) N^2 + N N^2 N
--------- = ------- = --- + ---
2 2 2 2
N^2 / 2 , , , O (N 2).
-, - , . , , , , . , . , , -O .