8000 Update ExponentialSearch · AllAlgorithms/java@03b2195 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03b2195

Browse files
anahita-singlaabranhe
authored andcommitted
Update ExponentialSearch
< 8000 /div>
1 parent d53bc7e commit 03b2195

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

searches/ExponentialSearch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include <bits/stdc++.h>
44
using namespace std;
55

6-
int binarySearch(int arr[], int, int, int);
6+
int BinarySearch(int arr[], int, int, int);
77

88
// Returns position of first occurrence of
99
// x in array
10-
int exponentialSearch(int arr[], int n, int x)
10+
int ExponentialSearch(int arr[], int n, int x)
1111
{
1212
// If x is present at firt location itself
1313
if (arr[0] == x)
@@ -20,13 +20,13 @@ int exponentialSearch(int arr[], int n, int x)
2020
i = i*2;
2121

2222
// Call binary search for the found range.
23-
return binarySearch(arr, i/2, min(i, n), x);
23+
return BinarySearch(arr, i/2, min(i, n), x);
2424
}
2525

2626
// A recursive binary search function. It returns
2727
// location of x in given array arr[l..r] is
2828
// present, otherwise -1
29-
int binarySearch(int arr[], int l, int r, int x)
29+
int BinarySearch(int arr[], int l, int r, int x)
3030
{
3131
if (r >= l)
3232
{
@@ -40,11 +40,11 @@ int binarySearch(int arr[], int l, int r, int x)
4040
// If element is smaller than mid, then it
4141
// can only be present n left subarray
4242
if (arr[mid] > x)
43-
return binarySearch(arr, l, mid-1, x);
43+
return BinarySearch(arr, l, mid-1, x);
4444

4545
// Else the element can only be present
4646
// in right subarray
47-
return binarySearch(arr, mid+1, r, x);
47+
return BinarySearch(arr, mid+1, r, x);
4848
}
4949

5050
// We reach here when element is not present
@@ -58,7 +58,7 @@ int main(void)
5858
int arr[] = {2, 3, 4, 10, 40};
5959
int n = sizeof(arr)/ sizeof(arr[0]);
6060
int x = 10;
61-
int result = exponentialSearch(arr, n, x);
61+
int result = ExponentialSearch(arr, n, x);
6262
(result == -1)? printf("Element is not present in array")
6363
: printf("Element is present at index %d",
6464
result);

0 commit comments

Comments
 (0)
0