Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an ExperimentController class. The class will have the following methods: a. timeAddToFront( int numberOfItems, int seed, int min, int max): i. create an instance

Create an ExperimentController class. The class will have the following methods:

a. timeAddToFront( int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, insert random even numbers between min and max to the container using the addToFront() method.

iii. The method will return the time taken to add all the items to the container using addToFront().

b. timeAddToBack( int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, insert random even numbers between min and max to the container using the addToBack() method.

iii. The method will return the time taken to add all the items to the container using addToBack().

c. timeAddSorted( int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, insert random even numbers between min and max to the container using the addSorted() method.

iii. The method will return the time taken to add all the items to the container using addSorted().

d. timeProductdSorted( int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, prepend random even numbers between min and max to the first element of the container using the productSorted() method.

iii. The method will return the time taken to add all the items to the container using productSorted().

e. timeSortofUnsortedList(int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, insert random even numbers between min and max to the container using the addToBack() method.

iii. The method will call selectionSort().

iv. The method will return the time it took to sort the array.

f. timeSortOfSortedList(int numberOfItems, int seed, int min, int max):

i. create an instance of a RandomIntegerContainer

ii. for the specified numberOfItems, insert random even numbers between min and max to the container using the addToBack() method.

iii. The method will call selectionSort().

iv. The method will call selectionSort() again.

v. The method will return the time it took to sort the already sorted array.

image text in transcribed

import static org.junit. Assert. assertArrayEquals; import java.util.*; import org.junit. Test; public class Random IntegerContainer { private ArrayList arraylist; public Random IntegerContainer() { arraylist = new ArrayList(); public void addToFront(int x) { arraylist.add(0, x); public void addToBack(int x) { arraylist.add(x); public void addSorted(int x) { arraylist.add(x); selectionSort(); public void productsorted(int x) { int first = arraylist.remove(); arraylist.add(0, first * x); selectionSort(); public void selection Sort() { for (int i = 0; i arraylist; public Random IntegerContainer() { arraylist = new ArrayList(); public void addToFront(int x) { arraylist.add(0, x); public void addToBack(int x) { arraylist.add(x); public void addSorted(int x) { arraylist.add(x); selectionSort(); public void productsorted(int x) { int first = arraylist.remove(); arraylist.add(0, first * x); selectionSort(); public void selection Sort() { 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

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Determine the value of T (G) when G is a complete graph.

Answered: 1 week ago