Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/08a12ff8bab67268480dac45d57f2ce4 to your computer and use it in GitHub Desktop.
Save parzibyte/08a12ff8bab67268480dac45d57f2ce4 to your computer and use it in GitHub Desktop.
"""
Probar con arreglo numérico
"""
arreglo = [1, 2, 3, 10, 50, 80, 120, 150, 500, 1000]
print("Vamos a buscar en la siguiente lista:", arreglo)
busqueda = 500
indice = busqueda_binaria(arreglo, busqueda)
print("El elemento {} está en el índice {}".format(busqueda, indice))
"""
Probar con arreglo de cadenas
"""
arreglo = ["Albino", "Amanda", "Bambú", "Becerro", "Contaminación", "Cortina", "Trampolín"]
print("La otra lista es:", arreglo)
busqueda = "Cortina"
indice = busqueda_binaria(arreglo, busqueda)
print("El elemento {} está en el índice {}".format(busqueda, indice))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment