Help for Binary Tree Traversal for infix to postfix conversion

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2007
Posts: 2
Reputation: muzammilpn is an unknown quantity at this point 
Solved Threads: 0
muzammilpn muzammilpn is offline Offline
Newbie Poster

Help for Binary Tree Traversal for infix to postfix conversion

 
0
  #1
May 20th, 2007
Can any one help me in providing help
I am working on Tree Structure

My problem is to take input as an expression like a+b(c/t) and
Using Binary Tree converting it into postfix RPN ab+ct/
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Help for Binary Tree Traversal for infix to postfix conversion

 
1
  #2
May 20th, 2007
It's pretty simple first create a binary tree, then read the input and insert each element in appropriate place in teh tree, then read it back in postfix notation.
Let us know once you're done with the code if you need more help.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 716
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Help for Binary Tree Traversal for infix to postfix conversion

 
0
  #3
May 20th, 2007
>It's pretty simple first create a binary tree, then read the input and insert
>each element in appropriate place in teh tree, then read it back in postfix notation.
Brilliant.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Help for Binary Tree Traversal for infix to postfix conversion

 
0
  #4
May 20th, 2007
It isn't actually that difficult.

Find the operator with the lowest priority, store it as the root node with the left and right expressions as subnodes.
Repeat for both subnodes.

One thing that complicates it a little is characters that can act as both unary and binary operators (-).

Personally, I find using the stack much easier to complete such a task. Look here for ideas.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC