Word

advertisement
ALG0183 Algorithms & Data Structures
Assignment 1 Value 10%
Deadline: 12:35 pm Thursday, November 5th
Eindagi: 12:35 e.h. Fimmtudagur, Nóvember 5.
Late assignments will not be marked.
Optimising Quicksort
Background
In his talk “Selecting the Right Algorithm” at the 2001 AAAI Fall Symposium Series: Using
Uncertainty within Computation, Cape Cod, MA, November 2001, Michail G. Lagoudakis
presented results showing that the switch over point was platform dependent. He also showed
that an optimal policy included a switch over to Merge Sort as well. The aim of this assignment
is primarily to try and reproduce his findings. Links to Lagoudakis´s paper and talk are available
on the ALG0183 website.
Experimental parameters (according to Lagoudakis)
Average-case data of integer permutations. (No duplicate keys.)
Input sizes n = 10(10)100.
A minimum of 100 iterations for each measurement.
Instructions
Write and execute a program to determine the growth profiles for Insertion Sort, Merge Sort,
and Quicksort, Quicksort with a simple switch over to Insertion Sort at n = 10, and a hybrid
algorithm based on Lagoudakis´s Pentium/Linux figures. Note: the Quicksort should use the
first element as pivot. You can use the sorting code of Sorting.java (Lewis) and Sort.java
(Weiss) and the timing code of MaxSumTest.java on the ALG0183 website.
You will likely have to vary the amount of time allocated for an experimental run to ensure a
minimum of 100 iterations for each measurement. Note that it might be the case you need 1,000
or even 10,000 iterations to accurately determine a timing for a particular value of n. (Your
computer may be a lot faster than the computer Lagoudakis used.) Also, in experimental work
with Java, automatic garbage collection might influence the timing of a single run: a single
timing might be inexplicably much slower than the others.
1
ALG0183 Algorithms & Data Structures
Quicksort report The quicksort report should be structured as follows:
Title page (-2% if not present)
The title should be “Optimising Quicksort”. The title page must contain your name, the name of
the course (ALG0183 Algorithms & Data Structures) and the following statement: “This
assignment is all my own work. This work has not been submitted for assessment in any other
context. I have not knowingly allowed others to copy my work.” By including this statement, you
are agreeing with it. If you plagiarize material your degree will be at risk.
Platform & Experimental Parameters & Choice of sorts (1%)
Describe the technology platform used for the timing experiments. (0,25%) Describe the
experimental parameters and the reasons for differences, if any, from Lagoudakis´s choices.
(0,25%) Explain your choice of sorts (Lewis and/or Weiss). You may choose to use all of Lewis,
all of Weiss, or a mixture of Lewis and Weiss, but you must justify your choices. (0,5% )
Data Table (5% - 5*1,0%)
Provide a table of your timing measurements (averages of at least 100 iterations, possibly 1,000
or even 10,000). The table should be constructed with rows n = 10(10)100. Columns should be
in the order: Insertion Sort (1%), Merge Sort (1%), and Quicksort (1%), Quicksort with a simple
switch over to Insertion Sort at n = 10 (1%), and a hybrid algorithm based on Lagoudakis´s
Pentium/Linux figures (1%).
Graph (1% - 5*0,2%)
Provide a graph of your timing measurements given in your data table. X-axis is input size. Yaxis is time. Best-fit lines should be drawn through the points. Below the graph, provide the
equations of the best-fit lines.
Conclusions (1%)
State your conclusions about the growth profiles in terms of Big-Oh. (0,5% - 5*0,1%) Make clear
if you successfully replicated Lagoudakis´s work or not. If you did not, explain why. (0,25%)
State which algorithm has best performance and why. (0,25%)
Appendix A The Java source text (1%)
Provide a listing of all the code you have written or made use of. Make sure you acknowledge
the author of any code you have used by including comments to that effect. Use comments to
identify any code you wrote or changed.
Appendix B Timing tables (1% - 5*0,2%)
Provide timing tables which detail the number of iterations performed, the elapsed time, and the
average time calculations for N = 10(10)100. Provide separate tables for Insertion Sort, Merge
Sort, and Quicksort, Quicksort with a simple switch over to Insertion Sort at n = 10, and a hybrid
algorithm based on Lagoudakis´s Pentium/Linux figures.
2
ALG0183 Algorithms & Data Structures
Submission instructions
Submit a paper copy of your quicksort report. One corner should be stapled. Do not enclose
your submission in any folder or binder. Submit your paper copy at the start of the lecture hour
12:35 pm, Thursday, November 5th (or before). Also submit electronically via e-mail to
andy@unak.is a copy of your quicksort report (Word), and copies of all the Java source code.
The header of your e-mail message must be: “ALG0183 Assignment 1 <your name>”.
Bonus work
A bonus of 2% is available. What happens to hybrid quicksort´s performance when a median-ofthree pivot is used?
Submit additional code, tables, and graphs as necessary. Add a subsection to your conclusions
on any bonus work. Should bonus work result in an assignment mark over 10%, the additional
percentage points will be used in the overall grade calculation for ALG0183.
Advice
You are strongly advised not to interrupt the work of the CPU by launching other applications
while you measure. Close down any unnecessary applications before you start to measure.
Kepp your technology platform (machine and operating system) in the same state as you
perform measurements.
Marks will be lost for poor code layout and poor commenting.
Because you are conducting an experiment, unexpected things might happen, so you are
permitted two e-mail or phone or office consultations with the teacher.
Expect to work at least two hours for every 1% value of this assignment, i.e. 20 hours.
Dr Andy Brooks (andy@unak.is, GSM 869 3974)
mánudagur, 19. október 2009
http://staff.unak.is/not/andy/Algorithms0910/algorithms.htm
3
Download