Skip to content

Commit

Permalink
Created binary Search Algorithm
Browse files Browse the repository at this point in the history
Signed-off-by: LostHeart-Gaming <[email protected]>
  • Loading branch information
LostHeart-Gaming committed Oct 18, 2022
1 parent 3729356 commit 1362f70
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions binarySearch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
int binarySearch(int a[],int beg,int end ,int val)
{
int mid;
if(end>=beg)
{
mid=(beg+end)/2;
if(a[mid]==val)
{
return mid+1;
}
else if(a[mid]<val)
{
return binarySearch(a,mid+1,end,val);
}
else
{
return binarySearch(a,beg,mid-1,val);
}
}
return -1;
}


0 comments on commit 1362f70

Please sign in to comment.