Hi there, I'm trying to print the element of a binary search tree so i have the following procedures:
PROCEDURE bst_print_descending (root:node);
begin
if (root <> nil) then
begin
bst_print_descending (root^.right);
Canvas.TextOut (0,0 , IntToStr (root^.key)+ ' ['+ IntToStr(root^.level)+'] ');
bst_print_descending (root^.left);
end;
end;
procedure TForm1.DescendingOrder1Click(Sender: TObject);
begin
bst_print_descending (root);
end;
Now, there seems to be a problem with the Canvas.TextOut; when i click the button to print the elements, the program gives me an error, something about access violation at address 00000000..
Now, i tried moving the Canvas.TextOut to the second procedure and it worked...The only problem is, to print all the elements in a tree i need a recursive procedure
Again, the error occurs when i call a procedure with Canvas action in it.... so anyone has any suggestions??
Comments