I'm confused about the complexity of the following (the operation performed inside the inner loop is in constant time):
Pseudocode:
for i = 1 to n
for j = i to n
for k = i to j
x := x + 1;
end for
end for
end for;
Code:
for(i=1;i<=n;i++) {
for(j=i;j<=n;j++) {
for(k=i;k<=j;k++) {
x = x + 1;
}
}
}
O(n^3) ?