Computers and Technology
Computers and Technology, 28.07.2020 20:01, chackey

This lab assignment requires you to compare the performance of two distinct sorting algorithms to obtain some appreciation for the parameters to be considered in selecting an appropriate sort. Write a Quicksort and a Natural Merge Sort. They should both be recursive or both be iterative, so that the overhead of recursion will not be a factor in your comparisons. Be sure to justify your choice. Also, in your analysis, consider how your code would have differed if you had made the other choice. A Quicksort (or Partition Exchange Sort) divides the data into 2 partitions separated by a pivot. The first partition contains all the items which are smaller than the pivot. The remaining items are in the other partition. You will write four versions of Quicksort:
 Select the first item of the partition as the pivot. Treat partitions of size one and two as stopping cases.
 Select the first item of the partition as the pivot. Treat a partition of size 100 as a stopping case. Use an insertion sort to finish.
 Select the first item of the partition as the pivot. Treat a partition of size 50 as a stopping case. Use an insertion sort to finish.
 Select the median-of-three as the pivot. Treat partitions of size one and two as stopping cases.
Merge Sort is a useful sort to know if you are doing External Sorting. The need for this will increase as data sizes increase. The traditional Merge Sort requires double space. To eliminate this issue, you are to implement Natural Merge using a
linked implementation. In your analysis be sure to compare to the effect of using a straight Merge Sort instead.
Create input files of four sizes: 50, 1000, 2000, 5000 and 10000 integers. For each size file make 3 versions. On the first use a randomly ordered data set. On the second use the integers in reverse order. On the third use the
integers in normal ascending order. (You may use a random number generator to create the randomly ordered file, but it is important to limit the duplicates to <1%. Alternatively, you may write a shuffle function to randomize one of your ordered files.) This means you have an input set of 15 files plus whatever you deem necessary and reasonable. The size 50 files are to be turned in. The other sizes are for timing purposes. Your code needs to print out the sorted values. Files are available at on the course web page if you want to copy them. Your data should be formatted so that each number is on a separate line with no leading blanks. There should be no blank lines in the file.
Each sort must be run against all the input files. With five sorts and 15 input sets, you will have 75 required runs. For grading purposes, for each sort, turn in output only for the size 50 files. You will have 15 sets of output to turn in for the size 50 files.
Your program should access the system clock to get some time values for the different runs. The call to the clock should be placed as close as possible to the beginning and the end of each sort. If other code is included, it may have a large, albeit fixed, cost, which would tend to drown out the differences between the runs, if any. Why take a chance! If you get too many zero time data values or any negative time values then you must fix the problem. One way to do this is to use larger, files than those specified. Another solution is to perform the sorting in a loop, N times, and calculate an average value. You would need to be careful to start over with unsorted data, each time through the loop.
Turn in an analysis comparing the two sorts and their performance. Be sure to comment on the relative runtimes of the various runs, the effect of the order of the data, the effect of different size files, and the effect of different partition sizes and pivot selection methods for Quicksort. Which factor has the most effect on the efficiency? Be sure to consider both time and space efficiency. Be sure to justify your data structures. As time permits consider examining alternate methods of selecting the pivot for Quicksort. Also consider files of size 20,000 or additional random files - perhaps with 15-20% duplicates. Your analysis must include a table of the times obtained.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, araminaara691
How can a user open a blank presentation? 1.on the file menu, click new, and then click recent templates 2.on the file menu, click new, and then click blank presentation 3. on the view menu, click templates, and then click recent templates 4. on the view menu, click samples, and then click blank presentation
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, Liantic8738
List the five on-board vehicle subsystems
Answers: 1
image
Computers and Technology, 22.06.2019 19:20, sindy35111
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
image
Computers and Technology, 23.06.2019 01:40, hanjonez
Writing a modular program in visual c++. i am new to this and not sure what i am missing. i am getting the following error: baddate. cpp: in function ‘int main()’: baddate. cpp: 50: 3: error: ‘else’ without a previous ‘if’elsehere are the instructions and code: writing a modular program in c++in this lab, you add the input and output statements to a partially completed c++ program. when completed, the user should be able to enter a year, a month, and a day. the program then determines if the date is valid. valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.notice that variables have been declared for you. write the simulated housekeeping() function that contains the prompts and input statements to retrieve a year, a month, and a day from the user. include the output statements in the simulated endofjob() function. the format of the output is as follows: month/day/year is a valid date. ormonth/day/year is an invalid date. execute the program entering the following date: month = 5, day = 32, year = 2014. record the output of this program. execute the program entering the following date: month = 9, day = 21, year = 2002. record the output of this /* program name: baddate. cppfunction: this program determines if a date entered by the user is valid. input: interactiveoutput: valid date is printed or user is alerted that an invalid date was entered*/#include bool validatedate(int, int, int); using namespace std; int main(){// declare variablesint year; int month; int day; const int min_year = 0, min_month = 1, max_month = 12, min_day = 1, max_day = 31; bool validdate = true; // this is the work of the housekeeping() method// get the year, then the month, then the daycout< < "enter the year"< > year; cout< < "enter the month"< > month; cout< < "enter the day"< > day; // this is the work of the detailloop() method// check to be sure date is validif(year < = min_year) // invalid yearvaliddate = false; else if (month < min_month || month > max_month) // invalid monthvaliddate = false; else if (day < min_day || day > max_day) // invalid dayvaliddate = false; // this is the work of the endofjob() method// test to see if date is valid and output date and whether it is valid or notif(validdate == true); {// output statementcout<
Answers: 1
Do you know the correct answer?
This lab assignment requires you to compare the performance of two distinct sorting algorithms to ob...

Questions in other subjects: