Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE BuscarABB (txt: TString; a: Binario): BoolBinario;
- (* Devuelve el subarbol que tiene como raiz al elemento cuyo dato de texto es
- 'txt' y el discriminador 'hayBinario' del elemento devuelto es TRUE.
- Si 'txt' no pertenece a 'a', 'hayBinario' es FALSE. *)
- VAR resultado : Binario;
- encontroResultado : bool;
- BEGIN
- encontroResultado := FALSE;
- resultado = NIL;
- IF (TextoInfo(a^.elemento) == txt) THEN
- resultado := a;
- ELSIF NOT EsHoja(a) THEN
- IF TieneHijoIzquierdo(a) THEN
- resultado := BuscarABB(txt, a^.izquierdo);
- END;
- IF (resultado == NIL) AND (TieneHijoDerecho(a)) THEN
- resultado := BuscarABB(txt, a^.derecho);
- END;
- END;
- RETURN resultado;
- END BuscarABB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement