Quicksort, Mergesort, Selection Sort Program For N 5000
Quicksort, Mergesort, Selection Sort Program For N 5000
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
*a = *b;
*b = temp;
i++;
swap(&arr[i], &arr[j]);
return (i + 1);
quickSort(arr, pi + 1, high);
int generateRandomNumber() {
int main() {
// Set n value
int n = 6000;
srand(time(NULL));
arr[i] = generateRandomNumber();
printf("\n");
quickSort(arr, 0, n - 1);
// Record the end time
printf("\n\n");
free(arr);
return 0;
}
Program for selection sort using random number
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
minIndex = i;
minIndex = j;
temp = arr[minIndex];
arr[minIndex] = arr[i];
arr[i] = temp;
int generateRandomNumber() {
int main() {
// Set n value
int n = 5001;
srand(time(NULL));
arr[i] = generateRandomNumber();
printf("\n");
selectionSort(arr, n);
printf("\n\n");
free(arr);
return 0;