@@ -15,10 +15,10 @@ def __init__(self, chave):
15
15
# Metodos de Busca
16
16
def busca_recursiva (no , chave ):
17
17
if no is None :
18
- print (f' { chave } nao foi encontrado na arvore' )
18
+ print (f" { chave } nao foi encontrado na arvore" )
19
19
return
20
20
if no .chave == chave :
21
- print (f' { chave } foi encontrado na arvore' )
21
+ print (f" { chave } foi encontrado na arvore" )
22
22
return no
23
23
if chave > no .chave :
24
24
busca_recursiva (no .direita , chave )
@@ -50,14 +50,14 @@ def insere(no, chave):
50
50
51
51
52
52
# Metodos de Impressao
53
- IMPRIME_ARVORE = ''
53
+ IMPRIME_ARVORE = ""
54
54
55
55
56
56
def pre_ordem (no ):
57
57
global IMPRIME_ARVORE
58
58
if no is None :
59
59
return
60
- IMPRIME_ARVORE += str (no .chave ) + ', '
60
+ IMPRIME_ARVORE += str (no .chave ) + ", "
61
61
pre_ordem (no .esquerda )
62
62
pre_ordem (no .direita )
63
63
@@ -67,7 +67,7 @@ def em_ordem(no):
67
67
if no is None :
68
68
return
69
69
em_ordem (no .esquerda )
70
- IMPRIME_ARVORE += str (no .chave ) + ', '
70
+ IMPRIME_ARVORE += str (no .chave ) + ", "
71
71
em_ordem (no .direita )
72
72
73
73
@@ -77,7 +77,7 @@ def pos_ordem(no):
77
77
return
78
78
pos_ordem (no .esquerda )
79
79
pos_ordem (no .direita )
80
- IMPRIME_ARVORE += str (no .chave ) + ', '
80
+ IMPRIME_ARVORE += str (no .chave ) + ", "
81
81
82
82
83
83
# Acha a Altura da Arvore
@@ -142,7 +142,7 @@ def exclui(no, ch):
142
142
return True
143
143
144
144
145
- if __name__ == ' __main__' :
145
+ if __name__ == " __main__" :
146
146
arvore = Arvore (3 ) # Cria arvore (raiz)
147
147
# Insere varios valores na arvore
148
148
arvore = insere (arvore , 2 )
@@ -157,11 +157,11 @@ def exclui(no, ch):
157
157
busca_recursiva (arvore , 6 ) # Busca que imprime na propria funcao
158
158
159
159
if busca_linear (arvore , 6 ) is not None : # Retorna o NO ou None se nao encontrou
160
- print (' Valor encontrado' )
160
+ print (" Valor encontrado" )
161
161
else :
162
- print (' Valor nao encontrado' )
162
+ print (" Valor nao encontrado" )
163
163
164
- print (f' Altura: { altura (arvore )} ' )
164
+ print (f" Altura: { altura (arvore )} " )
165
165
166
166
# Exclui varios valores
167
167
exclui (arvore , 7 )
@@ -172,13 +172,13 @@ def exclui(no, ch):
172
172
# Chama os metodos de impressao
173
173
IMPRIME = ""
174
174
pre_ordem (arvore )
175
- print (f' PreOrdem: { IMPRIME } ' )
175
+ print (f" PreOrdem: { IMPRIME } " )
176
176
IMPRIME = ""
177
177
em_ordem (arvore )
178
- print (f' EmOrdem: { IMPRIME } ' )
178
+ print (f" EmOrdem: { IMPRIME } " )
179
179
IMPRIME = ""
180
180
pos_ordem (arvore )
181
- print (f' PosOrdem: { IMPRIME } ' )
181
+ print (f" PosOrdem: { IMPRIME } " )
182
182
183
183
# Mostra a altura da arvore apos remover os itens
184
- print (f' Altura: { altura (arvore )} ' )
184
+ print (f" Altura: { altura (arvore )} " )
0 commit comments