Trouble printing a BST line by line 
Author Message
 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



Fri, 25 Nov 2005 20:36:36 GMT  
 Trouble printing a BST line by line


Quote:
>do not know how to properly indent the tree line by line

What do you want to do?

Do you want to show multiple nodes in a line, or one node per line with an
indentation reflecting the level?

DoDi



Sun, 27 Nov 2005 09:30:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Read file line per line

2. Newbie question about moving thru table line by line

3. Can I turn 26 line mode to 50 line mode

4. Blank line between lines: HELP!

5. Same line screen printing...

6. Printing lines of memo fields

7. I like to print color Line graphics, text color in a hp deskject

8. QuickReport - Printing selected lines of memo fields

9. Print Screen 25/50 Lines

10. HELP: Print Screen 25/50 Lines

11. How to read two lines of input in Pascal but treat it as one line?

12. How can detect printer is on-line or Off-line!

 

 
Powered by phpBB® Forum Software