I want to calculate the complexity of theta of this nested loop:
for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) {
I would say that it is n ^ 3, but I do not think it is right, because each for loop does not go from 1 to n. I did some tests:
n = 5 → 10
10 → 120
30 → 4060
50 → 19600
So, it should be between n ^ 2 and n ^ 3. I tried the summation formula and so, but my results are too high. Although n ^ 2 log (n), but it is also wrong ...
Aaron source share