Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def busca_binaria(x, v):
- e = -1
- d = len(v)
- while e < d-1:
- m = (e + d) // 2
- if v[m] < x:
- e = m
- else:
- return d
- import random
- v = []
- for i in range(1000):
- v.append(random.randint(1, 1000))
- v.sort()
- print (busca_binaria(500, v))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement