Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JAVA) Does anybody can help me with this? I don't understand. 2. Create a generic class named ArraySorter that implements the SortsArray interface public interface

(JAVA) Does anybody can help me with this? I don't understand.

image text in transcribed

2. Create a generic class named ArraySorter that implements the SortsArray interface public interface SortsArray { void insertionSort(Comparator compare, E[] data); void bubblesort(Comparator compare, E[] data); void selectionSort(Comparator compare, E[] data); int getNumberofSwaps (); int getNumberofComparisons (); double getSortTime(); Each method should implement the named simple sort algorithm on the array data. Use the Comparator to determine the order of the items in the array. Sort the arrays in ascending order. The 'smallest' element should be in position 0, 1largest in data.length - 1. The methods should keep track of the number of comparisons, number of swaps and the amount of time it took to sort the array. To record the time taken, your code should call System.nanoTime at the beginning of each of the methods and save the value as the start time. It should then call System.nanoTime again at the end, and print the difference between the two times. The difference may be zero if your system clock does not update the time quickly enough, but otherwise should accurately report how many nanoseconds (billionths of a second) it took to execute your code. When the sort methods complete they should report the number of comparison, swaps, and the execution time in nanoseconds. Requirements Ensure that your implementation has the following characteristics: The Bigo for insertion and bubble sort on sorted data must be Bigo(n); o The number of swaps for all three sorts on sorted data must be 0

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

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions