Skip to main content

Posts

Showing posts with the label Stacks Data Structure In JAVA

Stack Data Structure

Question: What is stack ? Ans: Stack is a Linear data structure , Operations in Stack is performed in LIFO order   Stack: Stack is a Last in first out data structure [LIFO MODEL] Stack is Linear data structure in which insertion and deletions are allowed only at the end,called the top of the stack. As a stack is a Linear data structure , we can implement it using Array and LinkedList . bcse we know that Array and linkedlist is a linear data structure so can implement stack on Array and Linkedlist Operations In Stacks:  1)  Push elements onto the stack or push Operation : Kisi cheej ko push karke stack ke sabse upar dal dena Push keh lata hai , Iski time complexity O(1) hoti hai. 2)  Pop elements from the stack or pop Operations : To remove and return the top element from the stack, Stack ke top se element ko nikal lena Pop kehlata hai. Time Complexity O(1). pop will remove last inserted elements from stack Kisi bhi element ko stack se delete krne ko ham PoP bolte ha...