Question: !!!You will be creating a driver only for this assignment, however, the sorting methods should be entirely outside the main method.You will be creating a
!!!You will be creating a driver only for this assignment, however, the sorting methods should be entirely outside the main method.You will be creating a driver only for this assignment, however, the sorting methods should be entirely outside the main method.You will be creating a driver only for this assignment, however, the sorting methods should be entirely outside the main method.!!!
Within the driver class, please complete the following tasks:
Rewrite the code for the selection sort, the insertion sort, and the bubble sort so that the integer values within the array are sorted from highest to lowest. Please rename the methods as follows: sectionSort becomes reverseSelection, insertionSort becomes reverseInsertion, and bubbleSort becomes reverseBubble.
Before submitting the code, remove the block of code that prints out the contents of the array after each pass from within each method. Be sure to also delete any variables that are solely related to this task.
Include clear comments throughout the program that explain the well named variables and what functionality the various lines/small sections of code are completing as related to the execution of the program.
Here is the code you will be re writing backwards. copy it into a java program:
package sorting;
public class Sorting {
public static void main(String[] args) { int [] sortArray = {3, 9, 6, 1, 2, 5}; //original array to be sorted int [] sortArray2 = {3, 9, 6, 1, 2, 5}; //duplicate array to be sorted int [] sortArray3 = {3, 9, 6, 1, 2, 5}; //duplicate array to be sorted //print contents of unsorted original array System.out.println("-------Unsorted Array-------"); for (int index=0; index selectionSort(sortArray); System.out.println("----Sorted Array with selection sort----"); for (int index=0; index
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
