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/

Recommended Answers

All 3 Replies

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.

commented: Just that simple, huh? ;) +13
commented: learn 2 spell the properly. -2
commented: ++thekashyap; +2

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

Member Avatar for iamthwee

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.