I got those two algorithms with two for loops each - the first algorithm has in my opinion a quadratic running time. Does the second algorithm have the same running time - O(n^2)?
Algorithm 1:
for (int i = 1..n) {
for (int j = 1..n) {
// sort m[i, j]
}
}
Algorithm 2:
for (int i = 1..n) {
for (int j = i..n) {
// sort m[i, j]
}
}
I checked previous similar posts (Big O notation) but couldn't find anything to solve my problem - if you do so, please point me in the right direction.
Thanks!