Skip to content

Commit ec13a6f

Browse files
authored
Update binarySearchRecursive.cpp
Indentation
1 parent e321db8 commit ec13a6f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

searchingAlgo/binarySearch/binarySearchRecursive.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ using namespace std;
44
bool binse(int arr[],int l,int h,int x)
55
{
66
if(l>h)
7-
return -1;
7+
return -1;
88
int mid=l+(h-l)/2; //causes (l+h)/2 overloading so l+(h-l)/2 is preferred
99
if(arr[mid]==x)
10-
return mid;
10+
return mid;
1111
if(arr[mid]>x)
12-
return binse(arr,l,mid-1,x);
12+
return binse(arr,l,mid-1,x);
1313
else
14-
return binse(arr,mid+1,h,x);
14+
return binse(arr,mid+1,h,x);
1515
}
1616
int main() {
1717
int n;
1818
cin>>n;
1919
int arr[n];
2020
for(int i=0;i<n;i++)
21-
cin>>arr[i];
21+
cin>>arr[i];
2222
int x;
2323
cin>>x;//number to be searched
2424
int l=0,h=n-1;//lower limit and higher limit
2525
int pos=binse(arr,l,h,x);
2626
if(pos>=0)
27-
cout<<"The element is found at "<<pos+1;
27+
cout<<"The element is found at "<<pos+1;
2828
else
29-
cout<<"The element was not found";
30-
return 0;
29+
cout<<"The element was not found";
30+
return 0;
3131
}

0 commit comments

Comments
 (0)