diff --git a/Search/Interpolation Search.cpp b/Search/Interpolation Search.cpp new file mode 100644 index 000000000..7a9d67a67 --- /dev/null +++ b/Search/Interpolation Search.cpp @@ -0,0 +1,30 @@ +#include +int InterpolationSearch(int A[], int n, int x){ + int low =0; + int high =n-1; + while (low<=high){ + int mid = low + (((high-1)*(x-A[low]))/(A[high]-A[low])); + if(x==A[mid]) + return mid; // Found x, return (exit) + else if (x