Wednesday, February 4, 2009

Stack Data Structure
The process or steps involved in consecutively accommodating the following data into stack is this....
Push: Data_1
Push: Data_2
Push:Data_3
Push:Data_4
Pop: Data_4
Pop: Data_3
Pop: Data_2
Pop:Data_1Done ;-)

The expression is evaluated from the left to right using a stack:
push when encountering an operand and
pop two operands and evaluate the value when encountering an operation.
push the result
Like the following way (the Stack is displayed after Operation has taken place):
Input
Operation
Stack
1
Push operand
1
2
Push operand
1, 2
+
Add
3
4
Push operand
3, 4
*
Multiply
12
3
Push operand
12, 3
+
Add
15
The final result, 15, lies on the top of the stack at the end of the calculation.

Push and Pop is the operation use in the Stack Data structure were you're going to push an item into the tray which is the container of your datas, and pop is the getting the item out into the tray. The first item that was been push,will also be the first item that will come out to.

No comments: