S t a cks Stack is a linear structure in which insertion and deletion occur in LIFO pattern The end of the stack in which these operation s occur is called top of stack Any data can inserted or deleted only through the top Deletion is called pop and insertion is called push Some other terminologies used with stack are: peek , overflow, underflow
Implementation of Stacks in Python P ee k < stack>[top] Push < stack>.append(<item>) Pop < stack>.pop()
Stack Implementation in Python
Applications of stack To reverse a String : When we push every letter of a string till the last character and pop them back we get the string in reverse For polish notation : Stack plays a vital role in solving complex arithmetic expressions in any high-level language . For this stack is used to convert an expression in infix notation to postfix and vice versa. K C A T S