Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In bubbleSort.java (Listing 3.1 in your text) rewrite main() so it creates a large array and fillsthat array with data. You can use the following

In bubbleSort.java (Listing 3.1 in your text) rewrite main() so it creates a large array and fillsthat array with data. You can use the following code to generate random numbers:

for(int j=0; j { // random numbers long n = (long)( java.lang.Math.random()*(maxSize-1) ); arr.insert(n); }

BUBBLESORT

https://dmacc.blackboard.com/bbcswebdav/pid-2721734-dt-content-rid-29565697_1/courses/201801_CIS152_12928/bubbleSort.java

Insert 10,000 items. Display the data before and after the sort. Youll see that scrolling the display takes a long time. Take Screenshot Number 1 of the your changed code.

Next comment out the calls to display(). Add timing if necessary to see how long the sort itself takes. Need help with timing? See https://stackoverflow.com/questions/20211648/how-to-measure-time-taken-by-java-code. The time will vary on different machines. Take Screenshot Number 2 of your results.

Sorting 100,000 numbers will probably take less than 30 seconds. Now, select an array size that takes about this long and time it. Take Screenshot Number 3 of these results.

SELECTION SORT

https://dmacc.blackboard.com/bbcswebdav/pid-2721734-dt-content-rid-29565699_1/courses/201801_CIS152_12928/selectSort.java

Now, perform the same experiment on the Selection Sort. selectSort.java (Listing 3.2) using the same timing method you used. This will be Screenshot Number 4, Screenshot Number 5, Screenshot Number 6.

INSERTION SORT

https://dmacc.blackboard.com/bbcswebdav/pid-2721734-dt-content-rid-29565698_1/courses/201801_CIS152_12928/insertionSort.java

Now, perform the same experiment on the Selection Sort. insertionSort.java (Listing 3.3) using the same timing method you used. This will be Screenshot Number 7, Screenshot Number 8, Screenshot Number 9.

I. BUBBLE SORT

Paragraph and Screenshot Number 1

Paragraph and Screenshot Number 2

Paragraph and Screenshot Number 3

II. SELECTION SORT

Paragraph and Screenshot Number 4

Paragraph and Screenshot Number 5

Paragraph and Screenshot Number 6

III. INSERTION SORT

Paragraph and Screenshot Number 7

Paragraph and Screenshot Number 8

Paragraph and Screenshot Number 9

IV. SUMMARY AND CONCLUSION

Paragraph comparing Bubble, Insertion and Selection Sort algorithms.

Paragraph comparing Bubble, Insertion and Selection Sort timing.

Paragraph discussing the necessity to look at 10,000 and even larger arrays when testing timing.

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

=+ Who do you think is right? Why?

Answered: 1 week ago