int main() { clock_t t; double tot_exec_time; int l = 1, u = 100000, c = 100000; int arr[1000000], num, i; srand(time(0)); // Writing the array to a text file FILE *inputFile = fopen("input_array.txt", "w"); if (inputFile == NULL) { printf("Error opening file for writing.\n"); return 1; } for (i = 1; i <= c; i++) { num = (rand() % (u - l + 1)) + 1; fprintf(inputFile, "%d ", num); } fclose(inputFile); // Reading the array from the text file FILE *readFile = fopen("input_array.txt", "r"); if (readFile == NULL) { printf("Error opening file for reading.\n"); return 1; } for (i = 1; i <= c; i++) { fscanf(readFile, "%d", &arr[i]); } fclose(readFile); // Sorting the array using merge sort t = clock(); mergeSort(arr, 1, c); t = clock() - t; tot_exec_time = ((double)(t) / CLOCKS_PER_SEC); // Writing the sorted array to a text file FILE *sortedFile = fopen("sorted_array.txt", "w"); if (sortedFile == NULL) { printf("Error opening file for writing.\n"); return 1; } for (i = 1; i <= c; i++) { fprintf(sortedFile, "%d ", arr[i]); } fclose(sortedFile); printf("\n"); printf("Total time taken by Merge Sort is = %lf\n", tot_exec_time); return 0;