Skip to content

Commit 0b3ebb5

Browse files
Update Binary_search.py
1 parent a19a798 commit 0b3ebb5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Binary_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def binarySearch(arr, l, r, x):
1414
l = mid + 1 #l is initialised to the rightmost element of the middle so that the search could be started from there the next time
1515

1616
# If x is smaller, ignore right half
17-
else:
17+
elif x<arr[mid]:
1818
r = mid - 1 #r is initialised to the leftmost element of the middle so that the search goes till there only the next time
1919

2020
# If we reach here, then the element was not present
@@ -27,7 +27,7 @@ def binarySearch(arr, l, r, x):
2727
print("Enter the array with comma separated in which element will be searched")
2828
arr =[int(x) for x in input().split(',')] #the input array will of int type with each element seperated with a comma due to the split fucntion
2929
#map function returns a list of results after applying the given function to each item
30-
x = int(input("Enter the element you want to search in given array"))
30+
x = eval(input("Enter the element you want to search in given array"))
3131

3232
# Function call
3333
result = binarySearch(arr, 0, len(arr) - 1, x)

0 commit comments

Comments
 (0)