Stack
You can think of a stack as a list that has some operation restrictions where you can insert and delete at only one end of the list. LIFO is last in, first out, this is how the stack treats the elements it contains. The fundamental operations of the stack are push, pop and top. Push is the same as an insert but allows insertion only at the top of the stack. Top gets the last element inserted while pop removes the last element inserted.
Sometimes pop and top can be combined but they are still separate operations.
Usually you get stack underflow exception if you tried to pop from an empty stack and you get a stack overflow exception when you try to push into a full stack. In the below diagram, in order to get A, you need to pop C and then pop B and after that the last element in the stack is A.
0
sin
cos
tan
sin-1
cos-1
tan-1
π
e
xy
x3
x2
ex
10x
y√x
3√x
√x
ln
log
(
)
1/x
%
n!
7
8
9
+
MS
4
5
6
–
M+
1
2
3
×
M-
0
.
EXP
÷
MR
±
RND
C
=
MC
|
Document Actions