Skip to content

Commit 9c8ff78

Browse files
authored
Initial File
Binary Search
1 parent 57f2ab4 commit 9c8ff78

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

binary_search

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def binary_search(arr,x,left,right):
2+
while(left<=right):
3+
mid=left +(right-left)//2
4+
5+
if(arr[mid]==x):
6+
return mid
7+
8+
elif (arr[mid] < x):
9+
left=mid+1
10+
11+
else:
12+
right=mid-1
13+
return -1

0 commit comments

Comments
 (0)