Input | Action | Prefix Expression |
---|
A | Push into the stack | A |
B | Push into the stack | A, B |
C | Push into the stack | A, B, C |
D | Push into the stack | A, B, C, D |
^ | Pop
two elements and append operator as prefix and push expression back into stack. | A, B, ^CD |
^ | Pop two elements and append operator as prefix and push expression back into stack. | A, ^B^CD |
E | Push into the stack | A, ^B^CD, E |
F | Push into the stack | A, ^B^CD, E, F |
G | Push into the stack | A, ^B^CD, E, F, G |
- | Pop two elements and append operator as prefix and push expression back into stack. | A, ^B^CD, E, -FG |
* | Pop two elements and append operator as prefix and push expression back into stack. | A, ^B^CD, *E-FG |
H | Push into the stack | A, ^B^CD, *E-FG, H |
I | Push into the stack | A, ^B^CD, *E-FG, H, I |
/ | Pop two elements and append operator as prefix and push expression back into stack. | A, ^B^CD, *E-FG, /HI |
* | Pop two elements and append operator as prefix and push expression back into stack. | A, ^B^CD, **E-FG/HI |
/ | Pop two elements and append operator as prefix and push expression back into stack. | A, /^B^CD**E-FG/HI |
+ | Pop two elements and append operator as prefix and push expression back into stack. | +A /^B^CD**E-FG/HI |
J | Push into the stack | +A /^B^CD**E-FG/HI, J |
* | Pop two elements and append operator as prefix and push expression back into stack. | *+A /^B^CD**E-FG/HIJ |