public void do() {
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
// do something
for (int i = 1; i < rows - 1; i += 2)
for (int j = 1; j < columns - 1; j += 2) {
// do something
for (int i = 50; i > 0; i--)
// do something
for (int i = 1; i < rows - 1; i++)
for (int j = 1; j < columns - 1; j++)
// do something
}
In this case rows and column would equal:
rows = (size * 10) + 1;
columns = rows + 10;
where size
(n) is 1, 2, 4, or 8.
Since the rows
and columns
variables will increase with respect to the size and each loop will run over the rows and then the columns inside the loop can I say that this function would run in O(n^2)?
I am fairly new with the whole complexity of an algorithm would love some input on this. Thank so much.