P 1
P 1
method and compute its time complexity. Run the program for varied values of n> 5000 and record
the time taken to sort. Plot a graph of the time taken versus n. The elements can be read from a file
or can be generated using the random number generator.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int temp;
int min_idx = i;
min_idx = j;
temp = arr[i];
arr[i] = arr[min_idx];
arr[min_idx] = temp;
srand(time(NULL));
arr[i] = rand();
int main() {
double time_taken[num_values];
int n = n_values[i];
generateRandomArray(arr, n);
selectionSort(arr, n);
free(arr);
return 0;