Question: Q-Implement merge sort, and quick sort to sort a list of integers. The code for these algorithms .Each function must be accompanied by comments.* Start

Q-Implement merge sort, and quick sort to sort a list of integers. The code for these algorithms .Each function must be accompanied by comments.*Q-Implement merge sort, and quick sort to sort a list of integers.The code for these algorithms .Each function must be accompanied by comments.*Start here X *.CX 1 #include 2 #include 3 #include 4. //functionwhich generate the random numbers and return those numbers 5 int* generateNumbers()

Start here X *.CX 1 #include 2 #include 3 #include 4. //function which generate the random numbers and return those numbers 5 int* 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; LHO // If the element is present at the middle // itself if (arr(mid] x) return mid; == 70 71 72 73 74 75 76 77 // If element is smaller than mid, then // it can only be present in left subarnama if (arr[mid] > x) return binarySearch (arr, l, mid - 1, x); 78 // Else the element can only be present // in right subanaan return binarySearch(arr, mid + l, r, x); } 79 80 81 82 83 84 85 86 87 88 // We reach here when element is not // present in array return -1; } \/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; } WN 5 } 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 int 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!