Advertisement
danielperezunlpam

cargarABB

Jun 1st, 2019
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. /**
  2.  * @brief EJERCICIO 3 - Carga un elemento en un ABB
  3.  * @param arbolito ArbolBin<T>
  4.  * @param e T
  5.  */
  6. template <class T>
  7. void cargarABB(ArbolBin<int> &arbolito, T e) {
  8.     Nodo<int>** R = arbolito.raizArbol();
  9.     while (*R) {
  10.         if (arbolito.recuperar(*R) == e)
  11.             return;
  12.         else {
  13.             if (arbolito.recuperar(*R) > e)
  14.                 R = arbolito.hijoIzq(*R);        
  15.             else
  16.                 R = arbolito.hijoDer(*R);
  17.         }
  18.     }
  19.     arbolito.asignarNodo(e, *R);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement