mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-15 18:27:36 +00:00
Minor improvement
This commit is contained in:
parent
b9692267f9
commit
d44b888aeb
@ -9,7 +9,7 @@ def binarySearch(alist, item):
|
|||||||
midpoint = (first + last)//2
|
midpoint = (first + last)//2
|
||||||
if alist[midpoint] == item:
|
if alist[midpoint] == item:
|
||||||
found = True
|
found = True
|
||||||
print("Found")
|
print("Found [ at position: %s ]" % (alist.index(item) + 1))
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if item < alist[midpoint]:
|
if item < alist[midpoint]:
|
||||||
@ -17,9 +17,10 @@ def binarySearch(alist, item):
|
|||||||
last = midpoint-1
|
last = midpoint-1
|
||||||
else:
|
else:
|
||||||
first = midpoint+1
|
first = midpoint+1
|
||||||
|
|
||||||
if found == False:
|
if found == False:
|
||||||
|
continue
|
||||||
print("Not found")
|
# print("Not found")
|
||||||
return found
|
return found
|
||||||
print("Enter numbers seprated by space")
|
print("Enter numbers seprated by space")
|
||||||
s = input()
|
s = input()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user