Write a program that counts the number of basic steps needed for sorting an array of integer numbers. Implement the Selection Sort algorithm, and the Insertion Sort algorithm (and as challenge: the...


Write a program that counts the number of basic steps needed for sorting an array of integer<br>numbers.<br>Implement the Selection Sort algorithm, and the Insertion Sort algorithm (and as challenge: the<br>BubbleSort algorithm).<br>Use the following methods:<br>public static void insertionSort(int array[]) and<br>public static void selectionSort(int array[]).<br>Challenge: public static void bubbleSort(int array[]).<br>Each method sorts the array given as parameter. It also counts and prints the number of<br>comparison steps and the number of swap operations needed. You may re-use your code from<br>the previous lab.<br>In the main method, test and compare each algorithm with the following inputs:<br>1. an array of random numbers as input (use the same array for both algorithms!)<br>(You can use the following numbers: 4, 2, 9, 6, 23, 12, 34, 0, 1, 76<br>or create your own, big array with 1,000 elements or more)<br>2. an array that is already sorted<br>3. an array that is sorted in reverse order.<br>Remember this:<br>• an array gets changed inside of a method. So, make a copy of the original array and use<br>the copy as argument for each sorting method. Each method needs its own copy.<br>Submit your program and your comparison results (as online text below) for input cases<br>1, 2 and 3.<br>

Extracted text: Write a program that counts the number of basic steps needed for sorting an array of integer numbers. Implement the Selection Sort algorithm, and the Insertion Sort algorithm (and as challenge: the BubbleSort algorithm). Use the following methods: public static void insertionSort(int array[]) and public static void selectionSort(int array[]). Challenge: public static void bubbleSort(int array[]). Each method sorts the array given as parameter. It also counts and prints the number of comparison steps and the number of swap operations needed. You may re-use your code from the previous lab. In the main method, test and compare each algorithm with the following inputs: 1. an array of random numbers as input (use the same array for both algorithms!) (You can use the following numbers: 4, 2, 9, 6, 23, 12, 34, 0, 1, 76 or create your own, big array with 1,000 elements or more) 2. an array that is already sorted 3. an array that is sorted in reverse order. Remember this: • an array gets changed inside of a method. So, make a copy of the original array and use the copy as argument for each sorting method. Each method needs its own copy. Submit your program and your comparison results (as online text below) for input cases 1, 2 and 3.

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here