Skip to content

Instantly share code, notes, and snippets.

@salluzziluca
Last active November 2, 2021 19:52
Show Gist options
  • Save salluzziluca/d10abc19278fcea088bb56f82d02add9 to your computer and use it in GitHub Desktop.
Save salluzziluca/d10abc19278fcea088bb56f82d02add9 to your computer and use it in GitHub Desktop.
Busqueda Binaria
def busqueda_binaria(lista, item):
largo = len(lista)
min = 0
max =largo
posicion = None
while (min <= max and posicion == None):
medio = (min+max)//2
if lista[medio] == item:
posicion = medio
if lista[medio]<item:
min = medio +1
else:
max = medio -1
return posicion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment