Assignment 1
Assignment 1
Instructions: Your assignment should represent your own effort. However, you
are not expected to work alone. It is fine to discuss the exercises and try to find
solutions together, but each student shall write down and submit his/her solutions
separately. It is good academic standard to acknowledge collaborators, so if you
worked together with other students, please list their names.
For a programming task, your solution must contain (i) an explanation of your
solution to the problem, (ii) the Java code, in a form that we can run it, (iii) instruc-
tions how to run it. Also put the source code into your solution document. For all
programming tasks, it is not allowed to use any external libraries (“import”) if not
stated otherwise.
Please, include name, student ID and email address in your submission.
(18 Points)
2. Running Time Comparison — Maxsort
Add to your class ArrayUtility two static methods implementing the al-
gorithm Maxsort, that takes an unsorted array of integer numbers as input and sorts
it in descending order, by repeatedly doing the following:
• then, it searches the whole array excluding the first element for the greatest
value, and puts it to the second position.
The perform tests to find out which of the two implementations is faster. Is there
an array size for which the running times crosse over? (A size N would be such a
cross-over point if for inputs of size less than N , the running times of one algorithm
are better, while for inputs of size greater than N , the running times of the other
algorithm are better.)
To perform your measurements, write a test class that
2. for each array created, sorts it using the two implementations of Maxsort
and measures the running times; to measure the running time use the Java
method System.nanoTime() in the following way:
long startTime = System.nanoTime();
... the code being measured ...
long estimatedTime = System.nanoTime()-startTime;
(12 Points)
Deliverables. For each question, hand in the code that you wrote. For Question 2,
write also a short report where you describe your measurements and the results you
observed.