-
-
Save parzibyte/fae7cc8be353d8acae7e9928af1970f0 to your computer and use it in GitHub Desktop.
This file contains 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
arbol = Arbol("Luis") | |
arbol.agregar("María José") | |
arbol.agregar("Maggie") | |
arbol.agregar("Leon") | |
arbol.agregar("Cuphead") | |
arbol.agregar("Aloy") | |
arbol.agregar("Jack") | |
nombre = input("Ingresa algo para agregar al árbol: ") | |
arbol.agregar(nombre) | |
arbol.preorden() | |
arbol.inorden() | |
arbol.postorden() | |
# Búsqueda | |
busqueda = input("Busca algo en el árbol: ") | |
nodo = arbol.buscar(busqueda) | |
if nodo is None: | |
print(f"{busqueda} no existe") | |
else: | |
print(f"{busqueda} sí existe") | |
# Aquí tienes en "nodo" toda la información del nodo. Tanto su izquierda, derecha, dato y otros atributos que le hayas agregado |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment