Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA, MAKE THE CODE AS SIMPLE AS POSSIBLE, THANK YOU You will be implementing versions of two sorting algorithms. You will use them to

IN JAVA, MAKE THE CODE AS SIMPLE AS POSSIBLE, THANK YOU

You will be implementing versions of two sorting algorithms. You will use them to sort an array of strings in lexicographic order. All other requirements are listed below.

1. You should write a method in a class named Runner1 that will generate an array of random strings for testing. The method should take in a number representing the size of the list, and return an array of that many Strings. Each string should have a randomly generated length between 3 and 10 (that is, 3 length 10).

2. Implement another method in Runner1 to print out your array of strings. You should print a line for each string.

3. As another preliminary step, implement a method CopyArray in Runner1 that creates a new array of strings with identical values of a given one.

4. Now, write two methods inside Runner1, one named BubbleSort and the other named SelectionSort. Use parameters as you think appropriate. BubbleSort must implement the bubble sort algorithm we discussed in the class and SelectionSort must implement the selection sort algorithm we discussed in class. Note that both BubbleSort and SelectionSort must sort the strings given in the input array in lexiographic order.

5. Demonstrate that your code works by generating a random list of 20 strings (in an array), printing out the list before you sort it, and then printing out the list again after it is sorted using BubbleSort. For an identical list of 20 strings (copied right after the generation of the array that was given to BubbleSort as an input), show the list before and after the use of the SelectionSort method.

6. Write a class named Runner2 that will test the speed of your BubbleSort and SelectionSort methods by recording the time needed to sort an array of different number of Strings (For example, 2000, 3000, 4000, 5000, 6000, and 7000 Strings). Using this data, draw two lines on the same line-plot using MS Excel, one line for Bubble Sort and one for Selection Sort, where x-axis is the number of Strings in the array and y-axis is the runtime. On the MS Word document, (1) copy the plot and paste it, (2) report the configuration (processor speed and model, memory, and operating system) of the computer where you executed Runner2, (3) write what are the time complexities of Bubble sort and Selection sort algorithms, (4) write no more than four sentences on if (and how) your plot demonstrates the expected time complexities of Bubble sort and Selection sort algorithms. Submit the MS Word file with your source codes. Convert/Export your MS Word file to a PDF file and submit it with all other files.

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago