Created
February 16, 2018 02:18
-
-
Save danielnunesdc/62c406a1e104fddf4e8c57bffe082674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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