This flashcard is just one of a free flashcard set. See all flashcards!
7
Bubble Sort
public void bubbleSort(int [] a){
for (int i = 0; i < a.length - 1; i){
for (int j = 0; j < a.length - 1; j){
if (a[j] > a[j + 1]){
swap (a, j, j +1);
}
}
}
}
boolean swapped;
do {
swapped = false;
for (int i = 0; i < a.length-1; i++){
if (a [j] > a[j +1]){
swapped = true;
}
} while(swapped);
for (int i = 0; i < a.length - 1; i){
for (int j = 0; j < a.length - 1; j){
if (a[j] > a[j + 1]){
swap (a, j, j +1);
}
}
}
}
boolean swapped;
do {
swapped = false;
for (int i = 0; i < a.length-1; i++){
if (a [j] > a[j +1]){
swapped = true;
}
} while(swapped);
Flashcard info:
Author: hristiana86
Main topic: Informatik
School / Univ.: HS
City: Mannheim
Published: 14.06.2010