Fhernd

arbol_aleatorio_orden.py

Feb 13th, 2026
8,758
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.70 KB | Source Code | 0 0
  1. import random
  2.  
  3.  
  4. class ArbolNumerico:
  5.  
  6.     def __init__(self, cantidad=10, minimo=1, maximo=100):
  7.         self.valores_originales = [random.randint(minimo, maximo) for _ in range(cantidad)]
  8.         self.raiz = None
  9.  
  10.     # ==============================
  11.     # MÉTODO PRINCIPAL DE ORDENAMIENTO
  12.     # ==============================
  13.     def ordenar_como_bst(self):
  14.         """
  15.        Construye el árbol binario de búsqueda
  16.        insertando los valores uno por uno.
  17.        """
  18.         self.raiz = None
  19.         for valor in self.valores_originales:
  20.             self.raiz = self._insertar(self.raiz, valor)
  21.  
  22.     # ==============================
  23.     # MÉTODOS AUXILIARES
  24.     # ==============================
  25.     def _insertar(self, nodo, valor):
  26.         """
  27.        Inserta un valor respetando la propiedad BST:
  28.        menores a la izquierda, mayores a la derecha.
  29.        """
  30.         if nodo is None:
  31.             return {"valor": valor, "izq": None, "der": None}
  32.  
  33.         if valor < nodo["valor"]:
  34.             nodo["izq"] = self._insertar(nodo["izq"], valor)
  35.         else:
  36.             nodo["der"] = self._insertar(nodo["der"], valor)
  37.  
  38.         return nodo
  39.  
  40.     def recorrido_inorden(self, nodo=None, resultado=None):
  41.         """
  42.        Devuelve los valores ordenados (in-order traversal).
  43.        """
  44.         if resultado is None:
  45.             resultado = []
  46.  
  47.         if nodo is None:
  48.             nodo = self.raiz
  49.  
  50.         if nodo:
  51.             self.recorrido_inorden(nodo["izq"], resultado)
  52.             resultado.append(nodo["valor"])
  53.             self.recorrido_inorden(nodo["der"], resultado)
  54.  
  55.         return resultado
  56.  
  57.     def mostrar_estructura(self, nodo=None, nivel=0):
  58.         """
  59.        Muestra el árbol de forma jerárquica.
  60.        """
  61.         if nodo is None:
  62.             nodo = self.raiz
  63.  
  64.         if nodo:
  65.             self.mostrar_estructura(nodo["der"], nivel + 1)
  66.             print("   " * nivel + str(nodo["valor"]))
  67.             self.mostrar_estructura(nodo["izq"], nivel + 1)
  68.  
  69.     # ==============================
  70.     # FUNCIÓN AUXILIAR DE ENTRADA
  71.     # ==============================
  72.     @staticmethod
  73.     def main():
  74.         print("=== CREACIÓN DEL ÁRBOL CON VALORES ALEATORIOS ===")
  75.         arbol = ArbolNumerico(cantidad=10)
  76.  
  77.         print("Valores originales:")
  78.         print(arbol.valores_originales)
  79.  
  80.         print("\n=== ORDENANDO COMO ÁRBOL BINARIO DE BÚSQUEDA ===")
  81.         arbol.ordenar_como_bst()
  82.  
  83.         print("\nEstructura del árbol:")
  84.         arbol.mostrar_estructura()
  85.  
  86.         print("\nRecorrido inorden (resultado ordenado):")
  87.         print(arbol.recorrido_inorden())
  88.  
  89.  
  90. # Ejecutar
  91. if __name__ == "__main__":
  92.     ArbolNumerico.main()
  93.  
Advertisement
Comments
  • User was banned
  • Texnekar
    85 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • Nikyekar
    79 days
    # CSS 0.06 KB | 0 0
    1. We just shared HQ data on our channel: https://t.me/theprotocolone
Add Comment
Please, Sign In to add comment