Chapter 2.1: 2.1-1 through 2.1-4
Note: In your github repo please create the following directories:
You can use the above directory structure as a template for future assignments.
- homework/1 - contents of this homework.
- Should also contain a typeset pdf of your assignment.
- homework/1/source - any source files used to create your pdf (e.g., .tex, images, etc.).
- Do not upload any LaTeX temporaries (e.g., .aux, .log, etc.) or other non-source files.
Chapter 2.2: 2.2-1 through 2.2-3
Chapter 2 Problems*: 2-2abcd
*Problems can be found at the end of the chapters to summarize the whole chapter. These can be found under the "Problems" heading after section 2.3 (bottom of page 39).
Program 1: Insertion and Merge Sort
First, in your repo create the following directory structure:
- Implement the text's algorithm for Insertion Sort.
- Implement the text's algorithm for Merge Sort.
- Chart/graph the results of experimentation in a spreadsheet.
- Describe the results of your experimentation.
- insertion - implementation files/test scripts here
- test - output of trials here*
- merge - implementation files/test scripts here
- test - output of trials here*
*Please commit a dummy file here (e.g., a README). You should not commit your test results because they may take up a bit of space and can be generated on my end.
Note: You may use whatever language you want as long as it is supported on the lab machines. I am using Python3 as the example, but just change the extension to an appropriate choice if you do not wish to use Python.
What you should implement:
You may use the following to get you started:
- Algorithm files (algorithms only, but if you use Python you can set up a "__main__" for testing purposes):
- insertion.py - contains the algorithm implementation
- merge.py - contains the algorithm implementation
- ordered.py - tests over ordered data (i.e., [1, 2, ..., n]
- backward.py (i.e., [n, n-1, ..., 2, 1])
- random.py (i.e., generated by rand() or randint()
Your test programs should take a single command line parameter n. Your program should then randomly generate n integers in the range 0..1,000,000.
Your test files should also output (1) the original array and (2) the sorted array to stdout, which can be redirected to a file in your Bash script.
Bash scripts to automate testing:
- e.g., ordered.sh, backward.sh, random.sh
- A sample bash script that expects a program called insertion_sort.py and generates test results. You can run this with:
- A sample spreadsheet to organize your results. (Please put in the sort directory.) You should include tables/graphs of at least the following results:
- One table and accompanying graph associated with each algorithm.
- Three additional tables/graphs that compare the best, worst, and average cases across algorithms.
- A sample report on your results (Please put in the sort directory.)
The idea is that you should generate sufficient test results to see whether the plots of your data match your expectations of the associated functions. (Feel free to take the experiments as far as you need past my starting point to see what happens.)
Due: 09/21 at 11:59 p.m.