Professional Documents
Culture Documents
Bnar Mustafa
bnar.mustafa8@gmail.com
Spring 2022
1
Video of this lecture
• Part 1:
https://www.youtube.com/watch?v=lV-4ylf51yo&t=33s
• Part 2:
https://www.youtube.com/watch?v=X_MRXFFOVr8&t=5s1
• Part 3:
https://www.youtube.com/watch?v=yG1cq7Szdf8&t=22s
2
Stack Implementation
A stack is a storage element that stores information in such a
manner that the item stored last is the first item retrieved., the
point of access called the top of the stack, and the items may be
added to or deleted from the stack by (PUSH), and (POP)
instruction, the operation principle of stack based on (LIFO) Last
Input First to be Output.
• The two operations of a stack are the insertion and deletion of items.
However, nothing is pushed or popped in a computer stack. These
operations are simulated by incrementing or decrementing the stack
pointer register.
• To remove the top item, the stack is popped by reading the memory
word at address 3 and decrementing the content of SP.
Stack Base:- Contain the address of the bottom location in the reserved
block.
Stack Limit:- Contain the address of the other end of the reserved
block.
9
Expression Evolution
Arithmetic Expressions can be written in one of three forms:
• Infix Notation: Operators are written between the operands they operate
on, e.g. 3 + 4.
• Prefix Notation: Operators are written before the operands, e.g + 3 4
• Postfix Notation: Operators are written after operands. 3 4 +
y=
Solu:
Firstly transfer the expression to postfix notation to become
yab-cde*+\=
Then, use the stack to implement this formula step by step by pushing
all the identifiers and implementing each operation using two source
operands from top of the stack (pop two operands; perform the
operation and then push the result back to the stack) finally pop the
contains of the stack where the expression have been performed in
it by infix notation
Z = ( A - B) * ( C - D) * [ E + ( F / G)]
21