Do you need this or any other assignment done for you from scratch?
We have qualified writers to help you.
We assure you a quality paper that is 100% free from plagiarism and AI.
You can choose either format of your choice ( Apa, Mla, Havard, Chicago, or any other)
NB: We do not resell your papers. Upon ordering, we do an original paper exclusively for you.
NB: All your data is kept safe from the public.
You have been provided with starter code(seeMyCanvas)that includes the source co
You have been provided with starter code(seeMyCanvas)that includes the source code for each of the
sort methods discussed (bubble, selection, insertion, shell, merge, quick and radix) that are to
be evaluated. You must add code to each of the methods to count the number of comparisons
required to completely sort the data. Ensure that you generate and use the same data for each
sort. Remember that the sort methods replace the existing data (in place sorting) so you need
to copy over the sorted output array before each sort is called. You will also measure the time
required to sort the data using each method by timing the algorithm using the
System.nanotime method.
Requirements
Your program must report the following information:
1. The time required in microseconds, the number of comparisons required and the time
to execute a basic step (the comparison) in ns for each of the sort methods provided.
The basic step is determined by taking the time required to sort an array of a size n and
dividing by the number of basic steps for that algorithm. Report your results for data
sets of 20, 100, 10000, 50000 elements.
Produce a table that looks similar to this:
Comparison for array size of 20 (Averaged over 5 runs)
==========================================================
Sort Execution Time Compares Basic Step
Algorithm (ns) (ns)
———————————————————–
aSort xxx xxxxx xxx.x
bSort xxx xxxxx xxx.x
cSort xxx xxxxx xxx.x
dSort xxx xxxxx xxx.x
eSort xxx xxxxx xxx.x
fSort xxx xxxxx xxx.x
gSort xxx xxxxx xxx.x
———————————————————–
You will need to produce a table for each different data size. The results should be
averaged over a number of runs in order to get reliable results.
2. Create a random array of 100,000 positive integer values and then compare the
performance of using a linear search (method a) vs a sort/binary search (method b) of
the array. Search the array for -1 (it will not be found in the array). Use one of the 7
sorting techniques provided. Report the time required for both techniques and also
report the number of linear searches required that would justify sorting the data first.
3. In a Comment section at the TOP of your source file, provide answers to the following:
a. List in order (fastest to slowest) your selection of algorithm to use when the array
to be sorted contains 20 elements. Base this on your results
b. List in order (fastest to slowest) your selection of algorithm to use when the array
to be sorted contains 50000 elements.
c. At 50000 elements which sort has the lowest basic instruction set time? Does this
impact your selection of the fastest algorithm? Why?
d. In a table provide the following information for each algorithm:
Name
BIG O notation (time complexity – average case)
BIG O notation (space complexity – worst case)
Example Output to include in comment
Sort Algorithm Identification
==========================================================
Sort Sort Algorithm Big O Big O
Algorithm Name (time) (space)
———————————————————–
aSort ________ O(___) O(____)
bSort ________ O(___) O(____)
cSort ________ O(___) O(____)
dSort ________ O(___) O(____)
eSort ________ O(___) O(____)
fSort ________ O(___) O(____)
gSort ________ O(___) O(____)
———————————————————–
Implementation Notes:
Part 1:
You will need to make each method return the count – change the type of method from a
void to a long method.
To get counting to work without using a global variable, you will need to use recursive
counting in some of the methods. An example of recursive counting is shown below:/**
* A demonstration of recursive counting in a Binary Search
* @param array – array to search
* @param low – the low index – set to 0 to search whiole array
* @param high – set to length of array to search whole array
* @param value – item to search for
* @param count – Used in recursion to accumulate the number of comparisons made
*
(set to 0 on initial call)
* @return an array with the item index in the first value and the
*
count in the second value
*/
private static int[] binarySearchR(int[] array, int low, int high, int value, int
count)
{ int middle;
// Mid point of search
// Test for the base case where the value is not found.
if (low > high)
return new int[] {-1,count};
// Calculate the middle position.
middle = (low + high) / 2;
// Search for the value.
if (array[middle] == value)
// Found match return the index
return new int[] {middle, count};
else if (value > array[middle])
// Recursive method call here (Upper half of remaining data)
return
binarySearchR(array, middle + 1, high, value, count+1);
else
// Recursive method call here (Lower half of remaining data)
return
binarySearchR(array, low, middle – 1, value, count+1);
}
The code to do the counting should be modularized so that code duplication is minimized.
You can use method references (function pointers), and try to create a loop for each of the
array sizes requested.
NOTE: I have uploaded one starter file for the use and help in Assignment please use it properly.
Do you need this or any other assignment done for you from scratch?
We have qualified writers to help you.
We assure you a quality paper that is 100% free from plagiarism and AI.
You can choose either format of your choice ( Apa, Mla, Havard, Chicago, or any other)
NB: We do not resell your papers. Upon ordering, we do an original paper exclusively for you.
NB: All your data is kept safe from the public.
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount