I think the Big-O notation is n^2, but im not too sure.
for (int i = 0; i < n -1; i++) {
for (int j = 0; j < n – 1; j++)
if (x[j] > x[j+1]) {
temp = x[j];
x[j] = x[j+1];
x[j+1] = temp;
}
}
I think the Big-O notation is n^2, but im not too sure.
for (int i = 0; i < n -1; i++) {
for (int j = 0; j < n – 1; j++)
if (x[j] > x[j+1]) {
temp = x[j];
x[j] = x[j+1];
x[j+1] = temp;
}
}
Yes it's n^2. Ignore the constants, outer loops run n times, and inner loop runs n times for each n.