Reference no: EM133096841
Description:
The purpose of this question is to allow the student to independently compare the run time of various sorting and searching algorithms. This will allow the student to get a better understanding of time complexity. It also aims to build an appreciation of the effects that the size and organization of data have on the speed of algorithms.
The sorting algorithms that will be examined are:
a) Selection sort
b) Insertion sort
c) Merge sort
d) Quick Sort
All sorting algorithms must sort the arrays in descending order.
Each sorting and searching algorithm will be comparatively run on arrays of the following sizes:
1. fifty(50)
2. one thousand (1,000)
3. ten thousand (10,000)
4. one hundred thousand (100,000)
5. one million (1,000,000)
Sorting Methodology and Requirements:
1. Create acore datasetcalled "coreData" which must be a single array of size one million (1,000,000) integers filled with random numbers between one(1) and two million (2,000,000).
2. For each comparative sorting test, four(4)copies(one for each sort to be tested) consisting of the same data from "coreData"must be made. For example, if the comparative test is on one thousand (1,000) elements, four arrays of size (1000) should be made and filled with a copy of the first one thousand (1000) elements of "coreData".
All recorded times mustbe measured usingSystem.nanoTime() for consistency. An example of how to use it is given below.
long start = System.nanoTime();
//code to be tested
long end = System.nanoTime();
long timeTaken = end - start;
Test data size |
Time unit |
50 |
nanoseconds |
1,000 |
nanoseconds |
10,000 |
nanoseconds |
100,000 |
nanoseconds |
1,000,000 |
milliseconds |
Output requirements:
The name of each sorting algorithm tested and the time it took to sort the data must be shown grouped by the test data size. For example if the test data size is fifty (50), the time taken for all the sorting algorithms to sort the data must be shown one after another.
Searching Methodology and Requirements:
1. Create a core data set called "coreData" which must be a single array of size one million (1,000,000) integers filled with random numbers between one (1) and two million (2,000,000).This array must then be sorted in descending order. (You may use the sorted array from the first part).
2. For each comparative search test, you must search for the number2,500,000 (two million five hundred thousand). This number does not exist in the array and represents the worst case for both searches. You must repeat the tests 5 times with binary search and linear search, timing how long it takes to complete for each dataset size. Place the results in the table attached.
Attachment:- Methodology.rar