مطلوب هذا هوم ورك مني وماني فاهمه
اتمنى منكم تساعدوني في حلة
Java Code
public static void bubbleSort3(int[] x) {
int n = x.length;
boolean doMore = true;
while (doMore) {
n--;
doMore = false; // assume this is our last pass over the array
for (int k=0; k<n; k++) {
if (x[k] > x[k+1]) {
// exchange elements
int temp = x[k]; x[k] = x[k+1]; x[k+1] = temp;
doMore = true; // after an exchange, must look again
}
}
}
}//end method bubbleSort3
Note: In the kth pass, n – k + 1 keys still require ordering and k – 1 keys are in appropriate positions.