alonsosjumper

ABB Padre

Jun 7th, 2011
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. nodoABB PadreABB (nodoABB n, ABB A)
  2. {
  3. if (n == NODO_NULO)
  4. ERROR("PadreABB: Nodo inexistente");
  5. if (RaizABB(A) == n)
  6. ERROR("PadreABB: La raiz no tiene padre");
  7. return PadreABBaux(n->elto.clave,RaizABB(A));
  8. }
  9.  
  10. static nodoABB PadreABBaux(tClave c, nodoABB n)
  11. {
  12. if (n == NODO_NULO)
  13. return NODO_NULO;
  14. else
  15. {
  16. if (n->hizq != NODO_NULO)
  17. if (n->hizq->elto.clave == c)
  18. return n;
  19. if (n->hder != NODO_NULO)
  20. if (n->hder->elto.clave == c)
  21. return n;
  22.  
  23. if (n->hizq != NODO_NULO)
  24. if (n->elto.clave > c)
  25. return PadreABBaux(c, n->hizq);
  26. if (n->hder != NODO_NULO)
  27. if (n->elto.clave < c)
  28. return PadreABBaux(c, n->hder);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment