By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,789 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,789 IT Pros & Developers. It's quick & easy.

BinryTree Traversal preorder return preorder Expression as String

P: 7
Hi,

I have problem with following method that we used for BinryTree Traversal. The follow method is good so far.

Expand|Select|Wrap|Line Numbers
  1. public void preorderHelper(MyBinaryTreeNode rt){
  2.  if(rt==null)
  3.  return;
  4.  System.out.print(" "+rt.data);
  5.  preorderHelper(rt.left);
  6.  preorderHelper(rt.right); 
  7. }
  8.  
But,


Now I have to change this method in such a way that it will return String(which will contains preorder expression).


Expand|Select|Wrap|Line Numbers
  1. public String preorderHelper(MyBinaryTreeNode rt){
  2.   /*
  3.  
  4.  ??????????
  5.  */
  6. }
  7.  


Any Idea. Thank you in Advance.
Apr 23 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.