@Test public void shouldMoveNegativeElementsToTheLeftWithWithMoreNegativeElementsSorting() { int[] array = { 1, -2, -1, -3, 4, -6 }; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }
public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } }
SplitArray { public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } } }
SplitArray { public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } }  }
SplitArray { public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } }  void splitSorting(int[] array); void splitSwappingIterative(int[] array); void splitSwappingRecursive(int[] array); }
SplitArray { public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } }  void splitSorting(int[] array); void splitSwappingIterative(int[] array); void splitSwappingRecursive(int[] array);  }