I have a m * n matrix, and for each row I need to compare all the elements among them. For each pair that I find, I will call a function that will perform some calculations.
Example:
my_array -> {1, 2, 3, 4, 5, ...}
I take 1 and I have: (1,2)(1,3)(1,4)(1,5)
I take 2 and I have: (2,1)(2,3)(2,4)(2,5)
and so on
Using C, I wrote the following:
for (i=0; i<array_length; i++) {
for (k=0; k<array_length; k++) {
if (i==k) continue;
}
}
}
I was wondering if I can use the algorithm with less complexity.
source
share