Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I Really need help with my Driver class the main function is the problem, the output should look like this SortType, ArrayType, Array Size ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

I Really need help with my Driver class the main function is the problem, the output should look like this

SortType, ArrayType, Array Size --------------------------------------------------------------------------------------------------------------------------------------------------------------------- testTime1 testTime2 testTime3 testTime4 testTime5 testTime6 testTime7 testTime8 testTime9 testTime10 --- Average testTime

_______________________________________________________________________________________________________________________________________

Sample Output

BubbleSort, Equal, 1,000

--------------------------------------------------------------------------------------------------------------------

191112 105869 32156 31878 31782 59693 33915 42761 31835 28588 58958.9

SelectionSort, Equal, 1,000

--------------------------------------------------------------------------------------------------------------------

6178978 1077160 4346520 203510 169876 169370 169031 189110 168926 168830 1284131.1

InsertionSort, Equal, 1,000

--------------------------------------------------------------------------------------------------------------------

54990 49565 47539 47891 54455 47858 47396 47412 47388 47761 49225.5

BubbleSort, Random, 1,000

--------------------------------------------------------------------------------------------------------------------

8838428 2501037 5466853 991840 1002020 974357 1034771 901121 1033604 968611 2371264.2

SelectionSort, Random, 1,000

--------------------------------------------------------------------------------------------------------------------

4957374 1917113 1970590 1848484 1785022 1869207 1804157 1788345 1849464 1830821 2162057.7

InsertionSort, Random, 1,000

--------------------------------------------------------------------------------------------------------------------

5172407 2603500 2689329 225980 228721 297706 250314 235043 311123 276796 1229091.9

BubbleSort, Increasing, 1,000

--------------------------------------------------------------------------------------------------------------------

1476 1145 1079 1131 1104 1121 1130 1013 1015 1035 1124.9

SelectionSort, Increasing, 1,000

--------------------------------------------------------------------------------------------------------------------

2039647 2009135 1850353 1886047 1843365 1792060 1772120 1772111 1772035 1944492 1868136.5

InsertionSort, Increasing, 1,000

--------------------------------------------------------------------------------------------------------------------

1798 1510 1462 1504 1459 1461 1533 1560 1437 1483 1520.7

BubbleSort, Decreasing, 1,000

--------------------------------------------------------------------------------------------------------------------

774127 780207 777420 776562 800886 775011 774859 774635 774748 794453 780290.8

SelectionSort, Decreasing, 1,000

--------------------------------------------------------------------------------------------------------------------

1776708 1775741 1775165 1775232 1816181 1777162 1775683 1775201 1819986 1775779 1784283.8

BubbleSort, Increasing, 10,000

--------------------------------------------------------------------------------------------------------------------

8982 8756 8811 8735 9406 12465 8592 8516 8653 8538 9145.4

SelectionSort, Increasing, 10,000

--------------------------------------------------------------------------------------------------------------------

204013259 201744523 194572506 195642828 195749549 197695840 199005343 196029675 195982435 196820062 197725602.0

InsertionSort, Increasing, 10,000

--------------------------------------------------------------------------------------------------------------------

18139 16910 20397 19720 27087 16012 16413 16786 15941 15874 18327.9

BubbleSort, Decreasing, 10,000

--------------------------------------------------------------------------------------------------------------------

93032696 96034085 87551333 88123959 87183100 88661984 87835992 87152855 88224176 87307900 89110808.0

SelectionSort, Decreasing, 10,000

--------------------------------------------------------------------------------------------------------------------

201607878 200061596 196748291 206039299 208471119 208447962 209103309 204952725 205117767 202873459 204342340.5

InsertionSort, Decreasing, 10,000

--------------------------------------------------------------------------------------------------------------------

53908443 47481274 50561418 50572387 49996934 47557035 50806159 48784234 47897893 48063884 49562966.1

BubbleSort, IncreasingAndRandom, 10,000

--------------------------------------------------------------------------------------------------------------------

51884652 50479094 51374672 52624514 62330382 50190966 50267878 50128180 47477963 51394383 51815268.4

SelectionSort, IncreasingAndRandom, 10,000

--------------------------------------------------------------------------------------------------------------------

204142153 202736222 201443547 203024404 202335240 203071435 194312589 201748151 199246740 194467577 200652805.8

InsertionSort, IncreasingAndRandom, 10,000

--------------------------------------------------------------------------------------------------------------------

4520635 4357003 4237677 4243873 4861083 4215219 3927815 4576842 4273242 4363618 4357700.7

_______________________________________________________________________________________________________________________________________

this my code

import java.util.Arrays; import java.util.Random;

public class SortDriver implements SortDriverInterface {

public static void main(String[] args) { SortDriver d= new SortDriver(); //TestTimes testTimes= new TestTimes(); int[]arraySizes= {1000,10000}; for(int arraySize: arraySizes) { for(SortDriver.ArrayType arrayType: SortDriver.ArrayType.values()) { for(SortDriver.SortType sortType: SortDriver.SortType.values()) { Object[] object= d.runSort(sortType,arrayType, arraySize,10); Object[]testTimes= new Object[20]; System.out.println((arrayType)); System.out.println((sortType)); long end=System.currentTimeMillis(); long start=System.currentTimeMillis(); //showTestTimes(); System.out.print(end-start+" "); } System.out.println(); } } } @Override public Object[] runSort(SortDriverInterface.SortType sortType, SortDriverInterface.ArrayType arrayType, int arraySize, int numberOfTimes) { Object[]object= new Object[numberOfTimes*2+1]; SortDriver d= new SortDriver(); TestTimes testTimes= new TestTimes(); for(int i=0; i

}

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions