Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Selection Sort is named because the values in an unordered list, are selected, o

ID: 3899290 • Letter: S

Question

Selection Sort is named because the values in an unordered list, are selected, one by one, and added to the ordered list. The algorithm described below will probably not be found on any web-site because it is a beginner's attempt. But you must use this algorithnm to receive credit for this exercise This exercise uses three new ideas; .The "array" as a list of numbers The random number generator to produce an unordered list s. The selection-sort algorithm The steps to complete this exercise are; a Create and fill an array with a random (unsorted) sequence of numbers between 0 and 1,000,000 b Create a second array, the same size as the first and copy the random (unsorted) numbers into it. Use a loop to go from sorted[0] to sorted[n-1] d Find the largest element of array named unsorted. Swap this largest element of unsorted with sorted[i] e increment i by 1 rIfn>1 go back to step d Testing: to test this algorithm, Fill an array with a sequence of 200 random numbers. Display the values in 4 columns Display the values in 4 c bSort the array in ascending order d Sort the same values in descending order e. Display the values in 4 column

Explanation / Answer

Hi ,

below is the required program SelectionSort.java. As per algorithm given above, I have taken two arrays, find largest element of one array and swapped with corresponding element in other array. At the end I am printing the array in ascending as well as descending order.

SelectionSort.java

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote