The algorithm consists of iterations. In the -th iteration, we find the -th minimum element and swap it with the -th element in the array. This will result in an array sorted in non-decreasing order.
Asimptotika:
The algorithm consists of iterations. In the -th iteration, we find the -th minimum element and swap it with the -th element in the array. This will result in an array sorted in non-decreasing order.
Asimptotika:
for (int it = 0; it < n - 1; it++) {
for (int i = 1; i <= n - 1; i++) {
if (a[i] > a[i + 1]) {
swap(a[i], a[i + 1]);
}
}
}