Динамические структуры данных. Алексеев А.Ю - 58 стр.

UptoLike

function NullBT ( t : BinT ) : Boolean;
begin
NullBT := ( t = nil )
end { NullBT };
function RootBT ( t : BinT ) : Elem;
begin
if t <> nil then RootBT := t^.Info else Otkaz(1)
end { RootBT };
function LeftBT ( t : BinT ) : BinT;
begin
if t <> nil then LeftBT := t^.LSub else Otkaz(2)
end { LeftBT };
function RightBT ( t : BinT ) : BinT;
begin
if t <> nil then RightBT := t^.RSub else Otkaz(3)
end { RightBT };
function ConsBT ( e : Elem; LS, RS : BinT ) : BinT;
var b : BinT;
begin
if MaxAvail >= SizeOf ( Node ) then
begin
New ( b );
b^.Info := e;
b^.LSub := LS;
b^.RSub := RS;
ConsBT := b
end
else Otkaz(4)
end { ConsBT };
procedure DestroyBT( var b : BinT );
begin
if
b <> nil then
begin
DestroyBt ( b^.LSub );
DestroyBt ( b^.RSub );
Dispose ( b )
end
end
{ DestroyBT };
begin
end.
58
function NullBT ( t : BinT ) : Boolean;
begin
   NullBT := ( t = nil )
end { NullBT };

function RootBT ( t : BinT ) : Elem;
begin
   if t <> nil then RootBT := t^.Info else Otkaz(1)
end { RootBT };

function LeftBT ( t : BinT ) : BinT;
begin
  if t <> nil then LeftBT := t^.LSub else Otkaz(2)
end { LeftBT };

function RightBT ( t : BinT ) : BinT;
begin
  if t <> nil then RightBT := t^.RSub else Otkaz(3)
end { RightBT };

function ConsBT ( e : Elem; LS, RS : BinT ) : BinT;
 var b : BinT;
begin
    if MaxAvail >= SizeOf ( Node ) then
     begin
      New ( b );
      b^.Info := e;
      b^.LSub := LS;
      b^.RSub := RS;
      ConsBT := b
     end
    else Otkaz(4)
end { ConsBT };

procedure DestroyBT( var b : BinT );
begin
   if b <> nil then
     begin
      DestroyBt ( b^.LSub );
      DestroyBt ( b^.RSub );
      Dispose ( b )
     end
end { DestroyBT };
begin
end.

                                          58