Question
Lab Exercise 03.1 Selection Sort PLEASE USE JAVA USE SELECTION SORT NOT BUBBLE SORT Selection Sort is named because the values in an unordered list,
Lab Exercise 03.1
Selection Sort
PLEASE USE JAVA
USE SELECTION SORT NOT BUBBLE SORT
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 beginners attempt. But you must use this algorithm 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
The selection-sort algorithm
The steps to complete this exercise are;
Create and fill an array with a random (unsorted) sequence of numbers between 0 and 1,000,000.
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]
Find the largest element of array named unsorted.
Swap this largest element of unsorted with sorted[i]
increment i by 1
If n > 1 go back to step d
Testing: to test this algorithm,
Fill an array with a sequence of 200 random numbers.
Sort the array in ascending order
Display the values in 4 columns
Sort the same values in descending order
Display the values in 4 columns
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