Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED Complete JAVA CODE For this assignment, by sorting we mean sorting in ascending order. Write a program for Sorting algorithm: Bubble sort (the

I NEED Complete JAVA CODE

For this assignment, by sorting we mean sorting in ascending order. Write a program for Sorting algorithm:

Bubble sort (the most efficient version that minimizes iterations of the outer loop by tracking whether any swap was made in the last iteration and if so, at what position)

Input:

You must minimally first create the following types of input data, of sizes 1000, 2000, 4000, and 8000, and store them in one or more files.

a. random data

b. sorted data

c. reverse (descending) sorted data

Thus, there are at least 4 sizes in the above three categories. Create these 12 sets of input data once and use the same data on each algorithm. The elements of each input list should be in the range of 0 through 1 million. (You have at least 12 runs for each program, but those runs can be all in one session, or other combinations.)

Results:

Use the following criteria to compare the complexity of your programs for the above sorting algorithms:

i. Number of comparisons and

ii. Execution time

Submit:

1. Submit the three 8000-element data sets.

2. Submit the source code for the sorting programs.

3. Runs showing output (not the sorted output, but the results, namely the running time and the number of comparisons) for each sorting routine for each data set of each type. (There are a minimum of 60 such runs.)

4. A table of time and #comparisons for all algorithms for all sizes for each type of data.

5. Expected/theoretical performance (e.g., theta) for each case.

6. Are the theoretical and practical performance results consistent? Any anomalies and/or surprises?

7. Analysis and Discussion of your results vis--vis expectations

( IMPORTANT - I NEED COMPLETE JAVA CODE )

Tip:- You can use the below method for random and sorted numbers

void fill_random_numbers (int arr [], const unsigned int SIZE) { // Pre: SIZE is no more than a million, arr has been declared to be // an array of at least SIZE elements. // Post: The first SIZE elements of the array arr have been populated with // random integers between 0 and one million.

for (int i = 0; i < SIZE; i++) { arr[i] = round(rand() / double(RAND_MAX) * 1000000); } }

void fill_sorted_numbers (int asc [], int dsc [], const unsigned int SIZE) { // Pre: SIZE is no more than a million, and asc and dsc have been declared // to be arrays of at least SIZE elements. // Post: The first SIZE elements of the array asc have been populated with // integers between 0 and one million in ascending order, and dsc has // the same numbers in descending order.

int step = 1000000 / SIZE;

for (int i = 0; i < SIZE; i++) { asc[i] = dsc [SIZE-1-i] = step*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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

2 Let f(x)= x + 2 and g(x)=2x + 1 Find (fog)(x) and (gof)(x)

Answered: 1 week ago