dinamic de tipul record care con ine un cmp destinat memor rii informa iilor utile.
Var T : AdresaNod;
Algoritmul iterativ
y creeaz nodurile n ordinea apari iei lor pe niveluri:
y Se creeaz nodul-r d cin ; y Nodul-r d cin se ntroduce ntr-o coad ; y Pentru fiecaree nod extras se ceeaz
descendentul stng sau descendentul drept; y Nodurile nou create se ntroduc la coad ; y Procesul de construire a arborelui se ncheie cnd coada devine vid .
executia
PSEUDOCOD
y y y y y y y y y y y y y y y y y y y y y y
Program mi; type Arbore =^Nod; Nod= record Info :string; Stg,Dr:arbore end; var T:arbore; function Arb:Arbore; var r:arbore; s:string; begin readln(s); if s='' then arb :=nil else begin new(r); r^.info:=s; write('dati descendentul sting'); writeln('al nodului',s,':'); r^.stg:=arb; write('dati descendentul drept'); writeln('al nodului',s,':'); r^.dr:=arb;
y y y y y y y y y y y y y y y y y y y y
arb:=r; end; end; procedure afisarb(t:arbore; nivel :integer); var i :integer; begin if T <>nil then begin afisarb(T^.stg,nivel+1); for i:=1 to nivel do write(' '); writeln(T^.info); afisarb(t^.dr,nivel+1); end; end; begin writeln('dati radacina:'); t:=arb; afisarb(t,0); readln; end.
executia