diff --git a/Sorts/BubbleSort.java b/Sorts/BubbleSort.java index 9ca94954..7fd6afc5 100644 --- a/Sorts/BubbleSort.java +++ b/Sorts/BubbleSort.java @@ -18,9 +18,9 @@ class BubbleSort implements SortAlgorithm { */ @Override public > T[] sort(T[] array) { - for (int i = 0, size = array.length; i < size - 1; ++i) { + for (int i = 1, size = array.length; i < size; ++i) { boolean swapped = false; - for (int j = 0; j < size - 1 - i; ++j) { + for (int j = 0; j < size - i; ++j) { if (greater(array[j], array[j + 1])) { swap(array, j, j + 1); swapped = true;