Author: Joyce Buda


CMSC 350 Project 3
Quick Sort Optimizations through Hybridization
1. SpecificationPart 1Consider the attached QuickSort algorithm for sorting arrays and two algorithm optimization proposals QSopt1 andQSopt2, described below.QSopt1 executes QuickSort for the partitions of size larger than a given cutoff value (usually 10) and executes InsertionSort for sorting the partitions of size less than or equal to the cutoff value.QSopt2 executes QuickSort until all partitions’ size gets lower than a given cutoff value (usually 10) and then, executesthe improved Bubble Sort algorithm upon the whole "almost sorted" array.This project requires writing two Java programs detailed below in Part 1 (testing the functionality of the proposedalgorithms) and Part 2 (measuring and comparing their execution time).The algorithms for QuickSort, InsertionSort and BubbleSort are attached.Part 1 (Testing algorithms functionality)Design and implement a program to test the QSopt1 and QSopt2 algorithms. Define an array of size 100, populated withrandomly generated Integer or int values in the range 1 .. 999 and sort the array in increasing order by using thealgorithms QuickSort, QSopt1 and QSopt2. Display the array content before sorting and then after invoking each sortingalgorithm.Part 2 (Measuring the execution time)Design, implement and test a program which uses System.nanoTime() method to (1) measure the execution time of thethree sorting algorithms and (2) display the average execution time values for 105 runs. Do this for each of the array sizesspecified in the table below. Consider the arrays as being randomly populated with Integer or int values in the range 1 ..MAX as specified for each SIZE in the table below. After executing the program, fill-in the table cells with the measuredvalues and include the table in the solution description document.Note that due to the behavior of the JIT compiler, the execution time of the algorithms is much slower the first timesthey are run and therefore make sure to discard the measured values for the initial 5 runs.Table 1 - Average Execution TimeAverage execution time for 100 runsSIZE = 100MAX = 999SIZE = 1000MAX = 9,999SIZE = 10,000MAX = 99,999QuickSortQSopt1QSopt2The programs should compile without errors.Notes1. The array contents should not be displayed for Part 2.2. For Part 2, the three algorithms should be executed and their execution time should be displayed for the requiredarray sizes within the same program execution and without any user input.2. Submission RequirementsSubmit the following before the due date listed in the Calendar:1. Part1.zip including all .java files for Part 1 and Part2.zip including all .java files for Part 2. The source code should useJava code conventions and appropriate code layout (white space management and indents) and comments.2. The solution description document <YourSecondName>_P3 (.pdf or .doc / .docx) containing:(2.1) assumptions, main design decisions, error handling, (2.2) test cases and two relevant screenshots, (2.3) the table ofaverage execution time filled in with the measure values. (2.4) discussion of the results, (2.5) lessons learned and (2.6)possible improvements. The size of the document file (including the screenshots) should be of three pages, single spaced,font size 12.

See More
Try a College Course Free

Sophia’s self-paced online courses are a great way to save time and money as you earn credits eligible for transfer to over 2,000 colleges and universities.*

Begin Free Trial
No credit card required

26 Sophia partners guarantee credit transfer.

226 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 21 of Sophia’s online courses. More than 2,000 colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.