Professional Documents
Culture Documents
Stacks
Sidra Malik
sidra.malik@ciitlahore.edu.pk
Dynamic Implementation of Stacks
Top
x y z NULL
Array Implementation of Stacks…
Stack Definition
typedef struct stack {
int data;
struct stack *next;
} STACK;
A-B/(C*D^E) ABCDE^*/-
ABCDE^*/- -A/B*C^DE
Example: postfix expressions
• ( 5 + 6) * 9 +10
• (300+23)*(43-21)/(84+7)
• (4+8)*(6-5)/((3-2)*(2+2))
Example
• 3+4*5/6
345*6/+
• ( 5 + 6) * 9 +10
5 6 + 9 * 10 +
• (300+23)*(43-21)/(84+7)
300 23 + 43 21 - * 84 7 + /
• (4+8)*(6-5)/((3-2)*(2+2))
48+65-*32–22+*/