1.1 KiB
1.1 KiB
Sorting algorithms
Implement Bubble sort, Quicksort and Merge sort in the Sorting class as indicated below. The three methods return a sorted version of the original array. The comparison between the elements of the arrays is specified with an instance of Comparator.
class Sorting {
public static T[] bubblesort(T[] array, Comparator<T> comparator) { ... }
public static T[] quicksort(T[] array, Comparator<T> comparator) { ... }
public static T[] mergesort(T[] array, Comparator<T> comparator) { ... }
}
Using jqwik create a differential fuzzing strategy to test the three sorting algorithms at the same time. Create the test before any sorting implementation. Document any bug you find with the help of your tests.
NOTE:
- Do not use any existing implementation, write your own code.
- Use the provided project template as a starting point.
- In the project you can launch the tests with
mvn test.