Computers and Technology

You are given the source code for four sorting algorithms, namely, insertion sort, selection sort, quick sort, and merge sort. Each algorithm is implemented in a single java source file, e. g., quick sort is in file QuickSort. java. Each sorting algorithm has a small driver program to test the algorithm, e. g., QuickSortTest. java is a program that creates a quick sort object and instructs the object to sort an array with 1,000 random integer elements. The Test. java files are given to you to demonstrate how to create and call the sorting classes. You will not be using them for the lab; however, you will be using the files that implement the sorting algorithms Step 1:
Modify each sorting algorithm so that it keeps track of the number of comparisons it performs and the number of exchanges (swaps) it performs during a single sorting operation. Keep track of these numbers using two long integer counters; one to keep track of the number of comparisons and another to keep track of the number of swaps.
Step 2:
Write a driver program (i. e., a main program) that instantiates a selection sort, quick sort, merge sort, and insertion sort objects and then instructs each object to sort an array of 50,000 random integer elements, then 100,000 elements, then 200,000 elements, then 300,000 elements, and finally 400,000 elements. Your program should record the number of exchanges and comparisons for each algorithm andeach data set that was sorted. Your program should also keep track of how much time each sorting algorithm needed to sort each array. Hence, for each algorithm you should record the time elapsed for each of the five sorting processes.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, ruddymorales1123
What allows you to create a wireless connection among your smart devices
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, jabezslade22
What is the first view you place in your drawing?
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, jalaholmes2027
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
image
Computers and Technology, 23.06.2019 10:30, badpotterchris
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
Do you know the correct answer?
You are given the source code for four sorting algorithms, namely, insertion sort, selection sort, q...

Questions in other subjects:

Konu
English, 18.08.2021 07:50
Konu
Mathematics, 18.08.2021 07:50