type
  ptree = ^btree;
  btree = record
    key : integer;
    left,right : ptree;
  end;

Procedure DoWork(tr : ptree);
begin
end;{DoWork}
{-----------------}
procedure LRootR(var tr : ptree);
begin
  if tr <> nil then
   begin
    LrootR(tr^.left);
    DoWork(tr);
    LrootR(tr^.right);
   end;
end;

procedure RootRL(var tr : ptree);
begin
  if tr <> nil then begin
    DoWork(tr);
    rootRL(tr^.right);
    rootRL(tr^.left);
   end;
end;

procedure RLroot(var tr : ptree);
begin
  if tr <> nil then begin
    RLroot(tr^.right);
    RLroot(tr^.left);
    DoWork(tr);
   end;
end;

function CreateDecTree(num : byte) : ptree;
var ret : ptree;
begin
  if num = 0 then begin
   CreateDecTree := nil;
   exit;
  end;
  New(Ret);
  Ret^.key := num;
  Ret^.Left := CreateDecTree(num-1);
  Ret^.Right := CreateDecTree(num-1);
  CreateDecTree := ret;
end; {CreateIncTree}

function CreateIncTree(num,max : byte) : ptree;
var ret : ptree;
begin
  if num = max+1 then begin
   CreateIncTree := nil;
   exit;
  end;
  New(Ret);
  Ret^.key := num;
  Ret^.Left := CreateIncTree(num+1,max);
  Ret^.Right := CreateIncTree(num+1,max);
  CreateIncTree := ret;
end; {CreateIncTree}

Function Search(sk : integer; var pt : ptree): boolean;
begin
  Search := false;
  if pt^.key=sk then begin
   search := true;
   exit;
  end;
  if pt^.left <> nil then Search:=Search(sk,pt^.left);
  if pt^.right <> nil then Search:=Search(sk,pt^.right);
end;