For example if the condition is i<=n, and the n is decreasing in the loops, how can i calculate the time complexity? Lets say we have nested loops like below:
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
x = x + 1;
}
n = n - 1;
}
Or if the decrement of n is being done in the inner loop:
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
x = x + 1;
n = n - 1;
}
}