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).
Chapter 2.3: 2.3-3 through 2.3-6
Chapter 2 Problems: 2-1ab
Chapter 3.1: 3.1-1, 3.1-4, 3.1-7
Chapter 3.2: 3.2-1, 3.2-2
Chapter 3 Problems: 3-2, 3-4
Chapter 4.1: 4.1-1, 4.1-2
Chapter 4.3: Exercises 4.3-1 through 4.3-3
Chapter 4.5: Exercises 4.5-1, 4.5-3
Non-Chapter: Use the tabular method ("subtract and guess") to solve
- Chapter 4.3: Please use the substitution method from class to derive a Θ bound.
- Show all your work. You don't need to prove the bound, just derive it.
- Chapter 4.5: Use the master method as instructed (identify all figures, argue conclusions by the master method)
Due: 11/15 (via github)
Chapter 6.1: Exercises 1-1, 1-3 through 1-5
Chapter 6.2: Exercises 2-1, 2-3, 2-6
Chapter 6.4: Exercises 4-2
Due: 11/26 (via github)
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.
Building on the previous results, add new directories, source files, and tests for the following algorithms:
Please make sure to add the following:
- selection sort
- bubble sort
Implement the text's algorithm for the Max Subarray problem.
- Add a new report: report2.txt (or pdf) (in your sort directory).
- Augment your previous spreadsheet to accommodate the new results. (Include a graph of your random, sorted, and reversed data for each algorithm and add to your best, worst, and average case graphs that compare all algorithms.)
- Add a new toplevel directory called max to store your results.
- Add new test cases where n random values are timed for various values of n. (Experiment to determine the range/step for yourself.)
- Include a new spreadsheet in this directory documenting your results as well as a new report.
Implement the text's algorithm for Heapsort, Quicksort, and (randomized) Quicksort.
Add them to your xlsx sheets (try to consolidate into one file for sorting), and add a new report. Draw a conclusion about the best sorting algorithms so far.