1.) Generate an array of 10 random numbers between 1 - 100
2.) Copy the array to a temp array
3.) Call each of the methods to sort (bubble, selection, insertion, quick, merge), passing it the array
4.) In-between the calls, you are going to refresh the array to the original numbers.
5.) Inside of each sorting method, you are going to obtain the nanoseconds time, before and after the method Subtract the before time from the after time to obtain total time in nanoseconds
6.) Display the amount of time that the sort took
7.) Tell me which sort was fastest.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i, arr=9; //taking the size of the arrey
int randArray[arr];
for(i=0;i<arr;i++)
randArray[i]=rand()%100+1; //TO Generate number between 1 to
100
printf("\n Random number of the array:\n");
for(i=0;i<arr;i++)
{
printf("\nElement number %d : %d",i+1,randArray[i]);
}
return 0;
//output photo
}
Get Answers For Free
Most questions answered within 1 hours.