Advertisement
Guest User

MODULA 2 DE LA MUERTE

a guest
Apr 20th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROCEDURE BuscarABB (txt: TString; a: Binario): BoolBinario;
  2. (* Devuelve el subarbol que tiene como raiz al elemento cuyo dato de texto es 'txt' *)
  3.  
  4. VAR resultado : Binario;
  5. BEGIN
  6.  
  7.    resultado = NIL;
  8.    IF (TextoInfo(a^.elemento) == txt) THEN
  9.       resultado := a;
  10.    ELSIF NOT EsHoja(a) THEN
  11.       IF TieneHijoIzquierdo(a) THEN
  12.          resultado := BuscarABB(txt, a^.izquierdo);
  13.       END;
  14.       IF (resultado == NIL) AND (TieneHijoDerecho(a)) THEN
  15.          resultado := BuscarABB(txt, a^.derecho);
  16.       END;
  17.    END;
  18.    RETURN resultado;
  19.  
  20. END BuscarABB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement