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' *)
- VAR resultado : Binario;
- BEGIN
- 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