0
Q:

stack data structure

>>> from collections import deque
>>> myStack = deque()
>>> myStack.append('a')
>>> myStack.append('b')
>>> myStack.append('c')
>>> myStack
deque(['a', 'b', 'c'])
>>> myStack.pop()
'c'
>>> myStack
deque(['a', 'b'])
4
Stack is an ordered list of similar data type.
Stack is a LIFO(Last in First out) structure or 
we can say FILO(First in Last out).
push() function is used to insert new elements into the Stack and 
pop() function is used to remove an element from the stack. 
Both insertion and removal are allowed at only one end of Stack called 
Top. Stack is said to be in Overflow state when it is completely full 
and is said to be in Underflow state if it is completely empty.
0

New to Communities?

Join the community