Skip to content

Commit

Permalink
Merge pull request #39 from Shoaib19/Shoaib019
Browse files Browse the repository at this point in the history
incomplete binary search
  • Loading branch information
Shoaib19 authored Apr 10, 2023
2 parents 4cf9008 + 11ca583 commit 452a35f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions searching_algos/binary_search.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
void binary_search(int arr[],int size, int key)
int binary_search(int arr[],int size, int key)
{
// code here
int mid = size / 2;
if(arr[mid] == key)
return mid;
while(mid > 0 && mid < size)
{
if(key < arr[mid])
{
mid = mid / 2;
}
else if(key > arr[mid])
{

}
}
}

0 comments on commit 452a35f

Please sign in to comment.