Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 15, 2021 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/fae7cc8be353d8acae7e9928af1970f0 to your computer and use it in GitHub Desktop.
Save parzibyte/fae7cc8be353d8acae7e9928af1970f0 to your computer and use it in GitHub Desktop.
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