Advertisement
HeNrYTG50

Buscar

Nov 24th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. template <class Tipo>
  2. bool ArbolAVL<Tipo>::Buscar(const Tipo& ElementoABuscar) const
  3. {
  4. NodoAVL<Tipo> *actual;
  5. bool encontro = false;
  6. if (raiz == NULL)
  7. cout << "No puede buscar en un arbol vacio" << endl;
  8. else
  9. {
  10. actual = raiz;
  11. while (actual != NULL && !encontro)
  12. {
  13. if (actual->informacion() == ElementoABuscar)
  14. encontro = true;
  15. else
  16. {
  17. if (actual->informacion() > ElementoABuscar)
  18. actual = actual->ligaizquierda();
  19. else
  20. actual = actual->ligaderecha();
  21. }
  22. }
  23. }
  24. return encontro;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement