|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 2630 (0xa46)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
└─⟦d65440be7⟧ »DATA«
└─⟦this⟧
with Text_Io;
package body Arbres is
procedure Construire (Un_Element : Element; A : in out Arbre) is
begin
A := new Noeud;
A.E := Un_Element;
A.Gauche := null;
A.Droit := null;
end Construire;
function Est_Vide (A : Arbre) return Boolean is
begin
return (A = null);
end Est_Vide;
procedure Affectation (X : Arbre; Y : in out Arbre) is
begin
if X = null then
Y := null;
else
Y := new Noeud'(E => X.E, Gauche => null, Droit => null);
Affectation (X.Gauche, Y.Gauche);
Affectation (X.Droit, Y.Droit);
end if;
end Affectation;
procedure Creer_Arbre_Vide (A : out Arbre) is
begin
A := null;
end Creer_Arbre_Vide;
function Valeur_Arbre (A : Arbre) return Element is
begin
return A.E;
end Valeur_Arbre;
function Sous_Arbre_Gauche (A : Arbre) return Arbre is
begin
return A.Gauche;
end Sous_Arbre_Gauche;
function Sous_Arbre_Droit (A : Arbre) return Arbre is
begin
return A.Droit;
end Sous_Arbre_Droit;
function Egal (Left, Right : Element) return Boolean is
begin
return Est_Egal (Left, Right);
end Egal;
function Superieur (Left, Right : Element) return Boolean is
begin
return ">" (Left, Right);
end Superieur;
function Recherche (Un_Element : Element; A : Arbre) return Arbre is
Arbre_Temporaire : Arbre;
begin
Affectation (A, Arbre_Temporaire);
while not Egal (Un_Element, Arbre_Temporaire.E) loop
if Superieur (Un_Element, Arbre_Temporaire.E) then
Arbre_Temporaire := Sous_Arbre_Droit (Arbre_Temporaire);
else
Arbre_Temporaire := Sous_Arbre_Gauche (Arbre_Temporaire);
end if;
exit when Est_Vide (Arbre_Temporaire);
end loop;
return Arbre_Temporaire;
end Recherche;
procedure Inserer (E : Element; A : Arbre) is
Arbre_Temporaire : Arbre;
begin
Affectation (A, Arbre_Temporaire);
if Est_Vide (Arbre_Temporaire) then
Construire (E, Arbre_Temporaire);
else
if not Egal (E, Arbre_Temporaire.E) then
if Superieur (E, Arbre_Temporaire.E) then
Inserer (E, Arbre_Temporaire.Droit);
else
Inserer (E, Arbre_Temporaire.Gauche);
end if;
else
Text_Io.Put_Line ("Cet element existe deja");
end if;
end if;
end Inserer;
end Arbres;