In this assignment, rewrite the Bubble Sort, Selection Sort and Insertion Sort functions meeting the following requirements:
- Each function must be implemented using recursion
- Each function sorts a given array of numbers in descending order
Your main program should be calling these functions with an unsorted array of numbers and then printing the results of the sorted array on the screen. You may test these functions using any data you deem appropriate. One example is to code main as follows:
public static void main(String[] args)
{
int testArray1[] = {… (use your own test data) …};
int testArray2[] = {… (use your own test data) …};
int testArray3[] = {… (use your own test data) …};
recursiveBubbleSort(testArray1, …);
printArray(testArray1);
recursiveSelectionSort(testArray2, …);
printArray(testArray2);
recursiveInsertionSort(testArray3, …);
printArray(testArray3);
}
“printArray” in this example would be a function that prints the contents of the given array. You do not have to create such a function for this assignment, but you may find it useful to create one to help with testing.
Note that the parameters for the recursive functions in this example are not completely defined. The parameters you come up with will depend on the design of your recursive version of these sorting algorithms. The only requirement for the functions is that you must send in the array as one of the input parameters.
You also do not need to show the progression of the sorting within the algorithm, unless you find it helpful for your coding and debugging. Only show the arrays before and after the sort functions are called to show that they work.