These two algorithms sort the date in ascending order. Are these two sorting algorithms called bubble sorting?
1) First, it finds the smallest of the entire array using swap and putting it at index 0, etc.
Or other words → After each iteration, it pops the smallest value at the beginning of the array using swap.
for (int i = 0; i != arrayEnd - 1; i++) {
for (j = i + 1; j != arrayEnd; j++) {
if (A[i] > A[j]) {
temp = A[i];
A[i] = A[j];
A[j] = temp;
}
}
}
2) After each iteration, it pops the largest value at the end of the array using swap.
while (!isSorted) {
isSorted = true;
for (int i = 0; i < lastUnsorted; i++) {
if (A[i] > A[i + 1]) {
temp = A[i];
A[i] = A[i + 1];
A[i + 1] = temp;
isSorted = false;
}
}
lastUnsorted--;
}
Are they called bubble types?
source
share