Ok...ho risolto, grazie al tuo algoritmo ne ho scritto uno in Pascal che poi ho leggermente modificato per farlo funzionare meglio in Pascal.
Ecco il codice:
Codice:
Procedure Inserisci(VAR A:tipoalbero; Liv_Att,Pos_Padre:integer);
var ElemTemp:integer;
c:char;
begin
if Liv_Att=0 then
begin
write('Inserire elemento radice: ');
readln(elemtemp);
Inserisci(A,1,elemtemp);
end else
begin
if A=NIL then
begin
new(A);
A^.elem:=pos_padre;
A^.sx:=NIL;
A^.dx:=NIL;
end;
write('Esiste il figlio sinistro dell''elemento ',pos_padre,' del livello ',liv_att-1,'? ');
readln(c);
if (c='s') OR (c='S') then
begin
write('Inserire valore: ');
readln(elemtemp);
Inserisci(A^.sx,liv_att+1,elemtemp);
end;
write('Esiste il figlio destro dell''elemento ',pos_padre,' del livello ',liv_att-1,'? ');
readln(c);
if (c='s') OR (c='S') then
begin
write('Inserire valore: ');
readln(elemtemp);
Inserisci(A^.dx,liv_att+1,elemtemp);
end;
end;
End;