Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a complete Java program that implements two separate sorting algorithms: a bubble sort and a merge sort. The program should run each sort on

image text in transcribedimage text in transcribed

Create a complete Java program that implements two separate sorting algorithms: a bubble sort and a merge sort. The program should run each sort on three different sets of data An array of randomly generated integers A list of sorted integers A list of integers sorted in reverse order . Allow the user to specify the size of the array to sort. Test each sort to make sure that it produces correct output. Add functionality to count the number of array comparisons taking place during each sorting algorithm. For example, count the number of times the bubble sort compares the current index's cell value to that of its neighboring cell Run each sort for at least three different array sizes for each type of data set (random, sorted, reverse). For each sort/data set/array size combination, list the expected number of operations from an algorithmic analysis of these two algorithms. Then compare the theoretical results with the results from your program runs. Present the results in a tabular format. For example: Sort Theoretical Expectation Actual Performance Array Type Bubble Bubble Bubble Bubble Bubble Bubble Array Size 100 100 100 1000 1000 1000 Random Sorted Reverse Random Sorted Reverse Merge Merge Merge 100 100 100 Random Sorted Reverse Remember to run each sort and type for different values of N (arrays of different size). Analyze the results of the table in a brief statement, describe how you arrived at your theoretical expectations, andsust reasons for your conclusions. Create a complete Java program that implements two separate sorting algorithms: a bubble sort and a merge sort. The program should run each sort on three different sets of data An array of randomly generated integers A list of sorted integers A list of integers sorted in reverse order . Allow the user to specify the size of the array to sort. Test each sort to make sure that it produces correct output. Add functionality to count the number of array comparisons taking place during each sorting algorithm. For example, count the number of times the bubble sort compares the current index's cell value to that of its neighboring cell Run each sort for at least three different array sizes for each type of data set (random, sorted, reverse). For each sort/data set/array size combination, list the expected number of operations from an algorithmic analysis of these two algorithms. Then compare the theoretical results with the results from your program runs. Present the results in a tabular format. For example: Sort Theoretical Expectation Actual Performance Array Type Bubble Bubble Bubble Bubble Bubble Bubble Array Size 100 100 100 1000 1000 1000 Random Sorted Reverse Random Sorted Reverse Merge Merge Merge 100 100 100 Random Sorted Reverse Remember to run each sort and type for different values of N (arrays of different size). Analyze the results of the table in a brief statement, describe how you arrived at your theoretical expectations, andsust reasons for your conclusions

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions