0

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/

4
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by iamthwee
1

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.

Votes + Comments
++thekashyap;
learn 2 spell the properly.
Just that simple, huh? ;)
0

>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. :)

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.