-
public static long bubbleSort(Comparable<Integer>[] listOfObjects);
This method will sort the specified listOfObjects using the Bubble Sort algorithm.
Input Parameter: Comparable<Integer>[] listOfObjects - An array of Objects to be sorted.
These Objects must implement the Comparable interface, which is implemented by the
Integer class.
Method Returns: a long value containing the number of nano-seconds it took to
sort the specified listOfObjects. This value must be a positive long number.
-
public static long selectionSort(Comparable<Integer>[] listOfObjects);
This method will sort the specified listOfObjects using the Selection Sort algorithm.
Input Parameter: Comparable<Integer>[] listOfObjects - An array of Objects to be sorted.
These Objects must implement the Comparable interface, which is implemented by the
Integer class.
Method Returns: a long value containing the number of nano-seconds it took to
sort the specified listOfObjects. This value must be a positive long number.
-
public static long insertionSort(Comparable<Integer>[] listOfObjects);
This method will sort the specified listOfObjects using the Insertion Sort algorithm.
Input Parameter: Comparable<Integer>[] listOfObjects - An array of Objects to be sorted.
These Objects must implement the Comparable interface, which is implemented by the
Integer class.
Method Returns: a long value containing the number of nano-seconds it took to
sort the specified listOfObjects. This value must be a positive long number.
Integer
class in Java:
-
public static enum ArrayType {Identical, Random, Increasing, Decreasing, IncreasingAndRandom};
-
public static enum SortType {BubbleSort, SelectionSort, InsertionSort};
-
public static Comparable<Integer>[] getArrayOfIdenticalNumbers(int count);
This method will create and return an array of Integer objects, all representing
the same integer value. The size of the array is specified by the
count parameter.
Input Parameter: int count - The number of entries in the resulting array of Integers.
Method Returns: The created array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static Comparable<Integer>[] getArrayOfRandomNumbers(int count);
This method will create and return an array of Integer objects, each representing
a random integer value. The size of the array is specified by the
count parameter.
Input Parameter: int count - The number of entries in the resulting array of Integers.
Method Returns: The created array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static Comparable<Integer>[] getArrayOfIncreasingNumbers(int count);
This method will create and return an array of Integer objects. The Integer objects
will be arranged in increasing order (ex. 2, 4, 6, ...) in the resulting array.
The size of the array is specified by the
count parameter.
Input Parameter: int count - The number of entries in the resulting array of Integers.
Method Returns: The created array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static Comparable<Integer>[] getArrayOfDecreasingNumbers(int count);
This method will create and return an array of Integer objects. The Integer objects
will be arranged in decreasing order (ex. 100, 98, 96, ...) in the resulting array.
The size of the array is specified by the
count parameter.
Input Parameter: int count - The number of entries in the resulting array of Integers.
Method Returns: The created array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static Comparable<Integer>[] getArrayOfIncreasingAndRandomNumbers(int countIncreasing, int countRandom);
This method will create and return an array of Integer objects.
The first countIncreasing Integer objects
will be arranged in increasing order (ex. 2, 4, 6, ...) and
the last countRandom Integer objects
will be arranged in random order in the resulting array.
The size of the array is specified by the sum of the
countIncreasing and countRandom
parameters.
Input Parameter: int countIncreasing - The number of entries that are arranged in increasing order.
Input Parameter: int countRandom - The number of entries that are arranged in random order.
Method Returns: The created array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static Comparable<Integer>[] runSort(SortType sortType, ArrayType arrayType, int numberOfElements);
This method with call the appropriate sort specified by the sortType
parameter a total of 10 times.
Before each sort, the method will generate the appropriate type of array specified by the
arrayType and the array will contain the the number of elements
specified by numberOfElements. The method will also
save the run time of each call into a static, private array variable that
can be obtained by the getRunTimes() method specified below.
Input Parameter: SortType sortType - The desired sort, selected from the Sort.SortType enum.
Input Parameter: ArrayType arrayType - The desired type of array, selected from the Sort.ArrayType
enum.
Input Parameter: int numberOfElements - The number of elements that should be in the array to be
sorted.
Method Returns: The sorted array of Integers as an array of Objects that implement the
Comparable interface, which is implemented by the Integer class.
-
public static long[] getRunTimes();
Method Returns: The array of long values containing the run times from the previous test
case.
-
public static void clearRunTimes();
This method will clear the run times to all zero.
-
public static void main(String[] args);
This method will be where you run all three sorts on all the possible arrays specified above.
This method should also print out the run times for each sort in a table format, you must
include this table in your analysis (See below).
Please make sure that all your Java programs are in the default package.
Please submit the completed Java programs as a zip file containing only the classes
specified above to the
Mimir Platform Website
.
Please submit your analysis on Blackboard as a typed Microsoft Word file (.doc or .docx).
No other forms of submission will be accepted.