avlnode = record { node in the tree }
element: char;
bf : integer; {the balancing factor}
parent,
left,
right: avllink; { parent, left and right subtree }
end;
avl = avllink; { set type }
avlelement = char;
function compare(e1,e2 : avlelement):integer;
{+--- on entry - e1 and e2 are transfered in for a comparison
| on exit - compare returns +1 iff e1 > e2
| 0 iff e1 = e2
| -1 iff e1 < e2
+----------------------------------------------------------------------}
begin {compare}
if e1 > e2 then compare := 1
else if e1 < e2 then compare := -1
else compare := 0;
end; {compare}
procedure print(var out:text; e:avlelement);
{+--- on entry - e is contained in the list and is ready for output
| on exit - e has been written to the corresponding out file
+------------------------------------------------------------------------}