Advertisement
fahadkalil

Untitled

Oct 22nd, 2020
2,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def busca_binaria(vetor, alvo):    
  2.     min = 0
  3.     max = len(vetor) - 1
  4.     mid = (max+min) // 2
  5.  
  6.     ## desenvolver o restante
  7.  
  8. ## testando
  9. lista = [5, 89, 52, 11, 22]
  10. lista.sort() # ordena de forma crescente
  11.  
  12. print(busca_binaria(lista, 52)) # resultado: 3 [indice]
  13.  
  14.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement