July 2018
Beginner
202 pages
5h 4m
English
We need to improve the bubble sort algorithm by reducing the number of passes.
The steps to do this are as follows:
public void sortImprovement2(int[] numbers) { int i = 0; boolean swapOccured = true; while (swapOccured) { swapOccured = false; i++; for (int j = 0; j < numbers.length - i; j++) { if (numbers[j] > numbers[j + 1]) { swap(numbers, j, j + 1); swapOccured = true; ...Read now
Unlock full access