fahadkalil

Untitled

Oct 22nd, 2020
1,039
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.    
RAW Paste Data