Question: Write a generic method selectionSort based on the sort program of Fig. 19.4. Write a test program that inputs, sorts and outputs an Integer array

Write a generic method selectionSort based on the sort program of Fig. 19.4. Write a test program that inputs, sorts and outputs an Integer array and a Float array. [ Hint: Use > in the type-parameter section for method selectionSort,so that you can use method compareTo to compare the objects of the type that T represents.]

When complete, upload your .java source file and submit. NOTE: Your solution should contain three generic methods:

selectionSort

swap

dsiplayArray

Your class will also contain a main method that will generate test cases using arrays of type Integer and type Double. Each test array should be displayed first in its original order, and after sorting, in its sorted order.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!