The above function will perform preorder traversing on the tree. It's an recursive function, you have to pass the root node of the tree to the function.
Kalai Selvan T.
Bix Beiderbecke
Greenhorn
Joined: Jun 28, 2004
Posts: 15
posted
0
I understand how to do the preorder traversal, the problem is in the actual writing
Maybe this can help someone figure out what i'm doing wrong
Bix Beiderbecke
Greenhorn
Joined: Jun 28, 2004
Posts: 15
posted
0
the code should say savePreOrder(t.left) sorry
Kalai Selvan
Ranch Hand
Joined: Jul 07, 2004
Posts: 79
posted
0
Hi,
I hope the code fragment will solve ur problem.....
For the uninitiated, the answer was (as nicely demonstrated by Kalai Selvan T's example) that the output file was being recreated every time savePreOrder() was called (i.e. for each node in the tree). The resulting output file would simply have contained the data for a single tree node.