Skip to content

Instantly share code, notes, and snippets.

@danielnunesdc
Created February 16, 2018 02:18
Show Gist options
  • Select an option

  • Save danielnunesdc/62c406a1e104fddf4e8c57bffe082674 to your computer and use it in GitHub Desktop.

Select an option

Save danielnunesdc/62c406a1e104fddf4e8c57bffe082674 to your computer and use it in GitHub Desktop.
def BuscaSequencial(valor, vetor, tam):
if tam == 1:
if vetor[0] == valor:
return 0
else:
return -1
else:
index = BuscaSequencial(valor, vetor, tam-1)
if index < 0:
if vetor[tam-1] == valor:
index = tam-1
return index
vetor = [1, 9, 39, 4, 12, 38, 94, 37]
print BuscaSequencial(12, vetor, len(vetor))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment