Question: Q2-: Testing - Create a main function which is able to call the number generator and all algorithms. Apply the testing procedure: Sorting i) By
Q2-: Testing - Create a main function which is able to call the number generator and all algorithms. Apply the testing procedure: Sorting i) By using the function from Q1, generate 100 unique integers. Output the list in a 100data.txt or 100data.csv file. ii) Read the integers from the file in an array or linked list apply the algorithms to sort the list. :
Record the time taken by each of the algorithms iii) Repeat the process with 200 and 300 unique integers.
##Q1 ANSWRING::






MOCO O O 1 #include 2 #include 3 #include 4 //function which generate the random numbers and return those numbers 5 Fint* generateNumbers() { 6 //creating block to store 300 numbers 7 int *ptr=(int*) malloc(sizeof(int)*300); 8 //setting seed 9 srand (191022310); 10 //loop to generate numbers 11 for (int i=0;i= arr[lo] && x = 1) { int mid = 1 + (r - 1) / 2; 60 61 62 63 64 65 66 67 68 69 70 71 72 // If the element is present at the middle // itself if (arr[mid) x) return mid; 73 // If element is smaller than mid, then | 1/ it can only be present in left suban if (arr (mid) > x) return binarySearch(arr, l, mid - 1, x); 74 75 76 77 78 79 80 81 82 // Else the element can only be present // in right subantes return binarySearch(arr, mid + 1, r, x); +] 84 85 86 87 88 // We reach here when element is not // present in array return -1; L} \/Bubble sort to sort an array for binary and interpolation search void sort (int *ptr, int n) { for (int i=0;iptr[j]) { int temp=ptr[i]; ptr[i]=ptr[j]; ptr[j]=temp; } } } 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 Fint main() { //Block for storing 300 numbers int *ptr=(int*) malloc(sizeof(int) *300); // store numbers in block ptr=generateNumbers(); //printing the numbers for (int i=0;i 2 #include 3 #include 4 //function which generate the random numbers and return those numbers 5 Fint* generateNumbers() { 6 //creating block to store 300 numbers 7 int *ptr=(int*) malloc(sizeof(int)*300); 8 //setting seed 9 srand (191022310); 10 //loop to generate numbers 11 for (int i=0;i= arr[lo] && x = 1) { int mid = 1 + (r - 1) / 2; 60 61 62 63 64 65 66 67 68 69 70 71 72 // If the element is present at the middle // itself if (arr[mid) x) return mid; 73 // If element is smaller than mid, then | 1/ it can only be present in left suban if (arr (mid) > x) return binarySearch(arr, l, mid - 1, x); 74 75 76 77 78 79 80 81 82 // Else the element can only be present // in right subantes return binarySearch(arr, mid + 1, r, x); +] 84 85 86 87 88 // We reach here when element is not // present in array return -1; L} \/Bubble sort to sort an array for binary and interpolation search void sort (int *ptr, int n) { for (int i=0;iptr[j]) { int temp=ptr[i]; ptr[i]=ptr[j]; ptr[j]=temp; } } } 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 Fint main() { //Block for storing 300 numbers int *ptr=(int*) malloc(sizeof(int) *300); // store numbers in block ptr=generateNumbers(); //printing the numbers for (int i=0;i