-
Recursive print / overwriting output-file
Hi there,
at the moment i am doing some research to Genetic Programming. I have implemented some expression trees ((a + b) * c) but have some problems printing the tree. Therefor i use a recursive method like tihs:
public void printInOrder(){
if(left != null){
System.out.print(" (");
left.printInOrder();
}
System.out.print(" " + op);
if(right != null){
right.printInOrder();
System.out.print(" )");
}
}
Left and Right represent the Left-node and the Right-node of a Root-node. Look at the example function, the root is '*' and the left is a '+' and the right a 'c' etc..
*
/ \
+ c
/ \
a b
This works perfect and i have no problems printing the tree. The output is just as i wanted: (a + b) * c. But now i want everything to print to some output-file to save my trees. The problems is that the recursive method overwrites my file everytime it starts this method and therefor i only see the last part of the tree in the output-file.
Can someone say how i can print my trees without overwriting the output-file?
thnx Tindo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks