===== PascalABC.NET =====
type
Node = auto class
public
data: integer;
left, right: Node;
end;
procedure Add(var root: Node; x: integer);
begin
if root = nil then
root := new Node(x, nil, nil);
exit
if root.data > x then
Add(root.left, x)
else if root.data < x then
Add(root.right, x)
procedure Postfix(root: Node);
if root = nil then exit;
Postfix(root.left);
Postfix(root.right);
Print(root.data)
var s := Seq(51, 25, 73, 15);
var R: Node;
R := nil;
foreach var x in s do
Add(R,x);
Add(R, 31);
Add(R, 93);
Postfix(R);
end.
===== PascalABC.NET =====
type
Node = auto class
public
data: integer;
left, right: Node;
end;
procedure Add(var root: Node; x: integer);
begin
if root = nil then
begin
root := new Node(x, nil, nil);
exit
end;
if root.data > x then
Add(root.left, x)
else if root.data < x then
Add(root.right, x)
end;
procedure Postfix(root: Node);
begin
if root = nil then exit;
Postfix(root.left);
Postfix(root.right);
Print(root.data)
end;
begin
var s := Seq(51, 25, 73, 15);
var R: Node;
R := nil;
foreach var x in s do
Add(R,x);
Add(R, 31);
Add(R, 93);
Postfix(R);
end.