---
# System prepended metadata

title: Evaluation of Prefix and Postfix expressions using stack
tags: [data structure, stack]

---

[TOC]

# Coverting infix to postfix 

![](https://hackmd.io/_uploads/Sy1i30AO3.png)

<!-- postfix <op1><op2><operator> -->

# Evaluation pofix (pseudocode)

![](https://hackmd.io/_uploads/Sk36gkkFh.png)

![](https://hackmd.io/_uploads/rygyZ1kY3.png)


pseudocode

```

evaluationPrifix(expression){
    crate stack S object
    for (i <-0; i = length(expression) -1;i++){
    
            if (expressionp[i] is operand){
                S.Push(expression[i])
            }
            
        else( expression[i] is operator){
        
            op1<-S.pop()
            op2<-S.pop()
            result = commputing(expression[i],op1,op2)
            S.push(result)
            
        }
    }
    return top of stack
}
```



