mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-23 18:12:47 +08:00
formatting source-code for 153fb7b8a5
This commit is contained in:
@@ -12,12 +12,10 @@
|
||||
* \returns index where the value is found
|
||||
* \returns -1 if not found
|
||||
*/
|
||||
int InterpolationSearch(int A[], int n, int x)
|
||||
{
|
||||
int InterpolationSearch(int A[], int n, int x) {
|
||||
int low = 0;
|
||||
int high = n - 1;
|
||||
while (low <= high)
|
||||
{
|
||||
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)
|
||||
@@ -31,8 +29,7 @@ int InterpolationSearch(int A[], int n, int x)
|
||||
}
|
||||
|
||||
/** main function */
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
int A[] = {2, 4, 5, 7, 13, 14, 15, 23};
|
||||
int x = 17;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user