Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Input: Postfix expression E, output: Expression tree T
- initialize stack S;
- for j = 0 to E.size – 1 do
- if (E[j] is an operand) {
- Tree t = new Tree(E[j]);
- S.push(t*);}
- else {
- tree* t2 = S.pop();
- tree* t1 = S.pop();
- Tree t = new(E[j], t1, t2);
- S.push(t*);
- }
Add Comment
Please, Sign In to add comment