Question
// CORRECT THE ERRORS AND MAKE SURE IT RUNS PERFECTLY ON DEV C ++.PLEASE SHOW ME THE OUTPUT SCREENSHOT// //IT IS A C PROGRAM//// DO
// CORRECT THE ERRORS AND MAKE SURE IT RUNS PERFECTLY ON DEV C ++.PLEASE SHOW ME THE OUTPUT SCREENSHOT//
//IT IS A C PROGRAM//// DO NOT CHANGE THE CODE. JUST CORRECT THE ERRORS AND MAKE SURE IT RUNS ON DEV C++//
//C Code:
//including all the required header files #include } //function for interpolation search int interpolationSearch(int *arr, int n, int x){ // Find indexes of two corners int lo = 0, hi = (n - 1); // Since array is sorted, an element present // in array must be in range defined by corner while (lo <= hi && x >= arr[lo] && x <= arr[hi]) { if (lo == hi) { if (arr[lo] == x) return lo; return -1; } // Probing the position with keeping // uniform distribution in mind. int pos = lo + (((double)(hi - lo) / (arr[hi] - arr[lo])) * (x - arr[lo])); // Condition of target found if (arr[pos] == x) return pos; // If x is larger, x is in upper part if (arr[pos] < x) lo = pos + 1; // If x is smaller, x is in the lower part else hi = pos - 1; } return -1; } // A recursive binary search function. It returns // location of x in given array arr[l..r] is present, // otherwise -1 int binarySearch(int *arr, int l, int r, int x){ if (r >= l) { int mid = l + (r - l) / 2; // If the element is present at the middle // itself if (arr[mid] == x) return mid; // If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); // Else the element can only be present // in right subarray return binarySearch(arr, mid + 1, r, x); } // 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;i //printing the numbers for(int i=0;i<300;i++) printf("%d ",*(ptr+i)); return 0; } task 2:- //including all the required header files #include } //function for interpolation search int interpolationSearch(int *arr, int n, int x){ // Find indexes of two corners int lo = 0, hi = (n - 1); // Since array is sorted, an element present // in array must be in range defined by corner while (lo <= hi && x >= arr[lo] && x <= arr[hi]) { if (lo == hi) { if (arr[lo] == x) return lo; return -1; } // Probing the position with keeping // uniform distribution in mind. int pos = lo + (((double)(hi - lo) / (arr[hi] - arr[lo])) * (x - arr[lo])); // Condition of target found if (arr[pos] == x) return pos; // If x is larger, x is in upper part if (arr[pos] < x) lo = pos + 1; // If x is smaller, x is in the lower part else hi = pos - 1; } return -1; } // A recursive binary search function. It returns // location of x in given array arr[l..r] is present, // otherwise -1 int binarySearch(int *arr, int l, int r, int x){ if (r >= l) { int mid = l + (r - l) / 2; // If the element is present at the middle // itself if (arr[mid] == x) return mid; // If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); // Else the element can only be present // in right subarray return binarySearch(arr, mid + 1, r, x); } // 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;i // CORRECT THE ERRORS AND MAKE SURE IT RUNS PERFECTLY ON DEV C ++// //IT IS A C PROGRAM////DO NOT CHANGE THE CODE .JUST CORRECT THE CODE .PLEASE SHOW THE OUTPUT SCREENSHOT//
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started