Question
The purpose of this problem is to design experiments to determine what algorithm is used for a sorting method. In the Sorting programs directory on
The purpose of this problem is to design experiments to determine what algorithm is used for a sorting method. In the Sorting programs directory on moodle you will find a file MysterySorts.java which contains methods implementing four sorting algorithms: insertion sort, selection sort, heap sort, and quick sort. Instead of going by these names, the methods are called sort(i, ), for i = 0, 1, 2, 3 (in no particular order). If you create an array A of Integer (or other comparable type) and create an object s of type MysterySorts, then s.sort(i,A) will sort A into increasing order, where i is between 0 and 3, inclusive. There is also a method shuffleArray(A) which arranges A into random order. Write a program called SortIdentifier that will identify which algorithm is used for sort(i, ), 0 i 3. You may assume that there is a MysterySorts.java file in the same directory as your program. Your program takes no input. The output is four lines, with the sorting algorithm corresponding to sort(0, ) through sort(3, ). For example, if your program determines that sort(0, ) is insertion sort, sort(1, ) is quick sort, sort(2, ) is heap sort, and sort(3, ) is selection sort, then the correct output is: insertion quick heap selection The only valid outputs are the 4! = 24 different orderings of the four words. The class Sorts.java contains the implementations of the sorting algorithms. Note that the version of quicksort uses the right-most array element as the pivot.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started