Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. def bin_search(lst, index):
  2. stub = len(lst) / 2
  3. if index == lst[stub].id:
  4. return lst[index]
  5. elif index > stub:
  6. return bin_search(lst[stub:], index - stub)
  7. elif index < stub:
  8. return bin_search(lst[:stub], index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement