Data Structure

No Comments
SYMBOL POSTFIX STACK
3 3
↑ 3 ↑
2 3 2 ↑
+ 3 2 ↑ +
5 3 2↑5 +
* 3 2↑5 + *
4 3 2↑5 4 + *
↑ 3 2↑ 5 4 + *↑
3 3 2↑5 4 3 + *↑
- 3 2↑5 4 3↑*+ -
18 3 2↑5 4 3↑*+18 -
/ 3 2↑5 4 3↑*+18 9 -/
9 3 2↑5 4 3↑*+18 9/-


INPUT OPERAND1 OPERAND2 VALUE STACK
3 3
2 3 2
↑ 3 2 9 9
5 95
4 9 5 4
3 9 5 4 3
↑ 4 3 64 9 5 64
* 5 64 320 9 320
+ 9 320 329 329
19 329 18
9 329 19 9
/ 18 9 2 329 2
- 329 2 327 327





2)
Indorder:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,18
Postorder:
2,1,6,7,9,8,5,11,10,12,4,3,18,14,13
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment