Project 5: Sorting and Running Time Analysis
Start: Tuesday, 10/29; Due: Monday, 11/11, by the beginning of class
Overview
During lectures, we learned about various sorting and searching algorthms. This assignment will give you practice on implementing them. What's more, you will learn about running time analysis of algorithms. You should work on this project individually.
Part 1: Natural Merge Sort
During lectures, I went through the implementation of various sorting algorithms (bubble sort, quick sort, and merge sort). For this part of the project, you will learn about a variation of merge sort (called natural merge sort).
For this part of the project, you will complete the lab section of Chapter 5 in your textbook (Secton 5.16: Natural Merge Sort). You will complete the missing codes in NaturalMergeSorter.py
(in particular, the get_sorted_run_length()
method and the natural_merge_sort
method). Please follow the steps in the project description carefully, they should provide instructions on what you need to do for each method.
Please feel free to implement any helper functions to assist you. If your function is too long, and you can isolate any part of a function based on task, you should be constructing a helper function.
Please read and follow the instruction for the lab (in Section 5.16) carefully. You should be able to run your code as you're coding. Once you have finished, submit the code via the textbook webpage. You do not need to submit to Moodle for this task.
Part 2: A Report on Run Time Analysis of Sorting Algorithms
During lectures, I gave you an introduction on running time analysis. For this part of the lab, first please read Section 4.1 - 4.7, 4.10 (in Chapter 4) and Section 5.14 (in Chapter 5) of the textbook. You will not be graded on wether or not you had fnished your reading; but, I strongly suggest for you to read the above Sections in the textbook (so that you have a better idea of what to write for your report).During lectures, I went through the implementation of various sorting algorithms (bubble sort, quick sort, and merge sort). Given what you have learned about the running time analysis previously, you will write a report to analyze and compare the running time of bubble sort, quick sort, and merge sort empirically.
This report should be scientific in nature, and should deemphasize the process of writing code and focus on the emperical analysis of the running time of each sorting algorithm.
You are asked to compare the efficiency of bubble sort, merge sort, and quick sort. First, looking at each program, predict what the running time is for each algorithm (best case, worst case, and average case). Then, verify your predictions experimentally. That is, run your algorithms with randomly generated array of increasing sizes (for example, array of 10, 20, 30 ...) and write down the corresponding time for your algorithm to sort each array. How big would the arrays need to be before your algorithms (bubble sort, quick sort, and merge sort) are unable to produce an answer? Write down those sizes. You should present this data in tables or graphs.
In presenting numerical data in tables or graphs, your presentation is important. If you are comparing the results of two or more experiments, make sure that you place the results in the same table or the same graph so the reader can easily compare the numbers. Also, all numbers in a column should be positioned so that the decimal points are vertically aligned. (This rule applies even if the decimal point isn't explicitly shown.)
What you must do/hand in
For part 1 of this project, you wiil complete the code in Section 5.16 of the textbook. Please read the instructions in Section 5.16 carefully and submit your code accordingly via the Moodle link.
For part 2 of this project, you must save your report as report.doc
or report.txt
and submit it via Moodle.
Grading Guide
We will be using this grading guide when grading your lab.
Submission
Submit part 1 of this project via Section 5.16 of your textbook (be sure to read and follow the submission instruction).
Submit part 2 of this project: report.txt
or report.doc
, via Moodle. Be sure to select 2025 f-mcs-178-001, which is your lecture section, then click on the MCS-178 Project 5 Submission link.