![]() |
| ||
| inorder traverse I have a binary tree which I would like to get printed out inorder. Right now I have this recursice loop: public void inorder()This get the right order printed. The problem is that I want this function to return a String with the right order. |
| ||
| Re: inorder traverse Since you want to return a string, just save the string returned from each recursive call, plus the string of the data in the node you are looking at and add them all together: public void inorder() { |
| ||
| Re: inorder traverse Hello efus. in inorder() function you have a line System.out.print(" " + data);Replace this static method with own.Succesive collect nascent data in external buffer. buffer can be placed in own singleton class. 0. Initialize external buffer; --------------------------------- 1. Invoke root.inorder(); 2. Get external buffer as String 3. Clear external buffer public void inorder() {quuba |
| All times are GMT -4. The time now is 4:24 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC