Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION An array is said to be sorted if its elements are in either increasing or decreasing order. One way the selection sort algorithm

JAVA QUESTION

An array is said to be sorted if its elements are in either increasing or decreasing order. One way the selection sort algorithm works is by repeatedly taking the lowest element from an array and adding it to a new array, so that all the elements in the new array are sorted from lowest to highest. Create a SelectionSort class with a constructor that has an int array parameter, member variables originalArray and sortedArray, public method display() that displays the contents of the sorted array, private methods sort() that populates a new array with the elements of the original array in order from lowest to highest, and findLowest() that returns the index of the element containing the lowest value. Hint: Since elements of an array cannot actually be removed an element can be set to a very high value after determining its value is the lowest. Create client code SortedArray, which tests the SelectionSort class. Use the pseudocode below when implementing the SortedArray client code:

int[] myNums; SelectionSort sortedArray; prompt user for the number of values to populate array with myNums = new int[values]; populate array with random integers between 0 and 100 display contents of original array sortedArray = new SelectionSort(myNums); sortedArray.display();

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+5. How have these groups changed within the last three years?

Answered: 1 week ago