Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list = [2, 10, 14, 23, 45 ,56, 64, 74, 86,90]
- length = len(list)
- number = int(input("What number are you searching for? "))
- LowerBound = 0
- UpperBound = length - 1
- match = False
- while match == False and LowerBound ?? UpperBound:
- MidPoint = (LowerBound + UpperBound) // 2
- if list[MidPoint] == number:
- print("We have found your number!")
- match == True
- break
- elif list[MidPoint] < number:
- LowerBound = MidPoint + 1
- else:
- UpperBound = MidPoint - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement