#include <stdio.h>
int main() {
int N = 32;
int sum = 0;
for (int i = 1; i <= N*N; i = i*3)
for (int j = 1; j <= i; j++)
sum++;
printf("Sum = %d\n", sum);
return 0;
}
The outer loop is odd.
If the check was only with N (and not N * N), then i, increasing the multiplication by 3 each time, would mean n / 3 iterations of N for the outer loop?
But the check is performed with N * N or N ^ 2, so it is understood that it will grow by
N^2 / 3 ??? (n squared divided by 3) Is that correct?
If I play with different values of N, say, doubling each time, the cycle I (by itself) does not increase by much. as a logarithmic growth). How can I express it mathematically?
Then what do you think of the inner cycle? If it increases to i each time, how can I express it mathematically? How to associate the inner loop with N?
I would like to: a) be able to mathematically express "complexity" in terms of N. Then the next step, b) is to use the notation with large O.
It confuses this. Any help would be greatly appreciated.