Trouble printing a BST line by line

Hi there,

been stuck on this problem for a couple of weeks and do not know how

to solve it any help greatly appreciated

do not know how to properly indent the tree line by line

procedure LevelOrderQueue(T: SearchTree);

var

Q: PQueue;

Z: TreePtr;

begin

if (T <> Nil) then

begin

PMakeNull(Q);

Z := T;

PutInQueue(Z, Q);

writeln(Z^.aWord:40); { put root in middle of page}

while not(QEmpty(Q)) do

begin

Z := DeQueue(Q);

{if Z^.level = m then ... not sure how to indent each

element

write(Z^.aWord:???)

else

writeln(Z^.aWord:???);

}

if Z^.Left <> nil then

PutInQueue(Z^.Left,Q);

if Z^.Right <> nil then

PutInQueue(Z^.Right,Q);

end;

end;

end;

any help greatly appreciated

i put a level element in the tree data structure but not really sure

how to use it

Barry Hynes

Summerside, PE

Canada