Stack Data Structure, Push, Pop and Peek Operations , Applications of Stack

Stack is a linear data structure. It is collection of ordered data elements. It is also known as LIFO system (last in first out). It means in this data structure if an element is inserted (push) at last then it will be deleted (pop) at first. Push and pop operations are performed on top of the stack. We can use array and linked list representation to form Stack in memory. Daily life examples of stack is book self, almirah, cards etc.
स्टैक एक लीनियर डाटा स्ट्रक्चर है। यह क्रमबद्ध डाटा एलेमेंट्स का संग्रह है। इसे LIFO (लास्ट इन फर्स्ट आउट) सिस्टम के नाम से भी जाना जाता है अर्थात स्टैक में यदि किसी एलिमेंट को अंत में इन्सर्ट(पुश) किया जाता है तब उसे सबसे पहले डिलीट(पॉप) किया जाता है। पुश एवं पॉप संक्रियाए स्टैक के टॉप पर की जाती है। हम अरे एवं लिंक्ड लिस्ट में से किसी एक का प्रयोग कर मेमोरी में स्टैक तैयार कर सकते है। दैनिक जीवन में स्टैक के उदाहरण है - बुक शेल्फ, अलमीराह, ताश के पत्ते इत्यादि।        
















Following 3 types of operations are performed on stack-
स्टैक पर निम्न तीन संक्रियाए की जा सकती है -

1.) Push:- To insert or add a new element into the stack is called push operation. This work is performed on top of stack. When we insert a new element then we should make top = top + 1. if top=N-1 it means stack is full and push operation is performed then Overflow Condition will occur.
स्टैक में किसी नए एलिमेंट को जोड़ना, पुश ऑपरेशन कहलाता है। यह कार्य स्टैक के टॉप पर किया जाता है। जब किसी नए एलिमेंट को जोड़ा जाता है, तब टॉप को एक से बढाया जाता है। यदि top=N-1 अर्थात स्टैक फुल हो एवं पुश ऑपरेशन किया जाये , तब ओवरफ्लो कंडीशन उत्पन्न होती है।    

2.) Pop:- To remove or delete an element from stack is called pop operation. This work is also done on top of the stack. After deletion of element from stack we should make top = top -1. if top=-1 it means stack is Empty and pop operation is performed then Underflow Condition will occur.
स्टैक से किसी एलिमेंट को हटाना/ निकालना, पॉप ऑपरेशन कहलाता है। यह कार्य स्टैक के टॉप पर किया जाता है। जब किसी एलिमेंट को निकाला जाता है, तब टॉप को एक से घटाया जाता है। यदि top=-1 अर्थात स्टैक खाली हो एवं पॉप ऑपरेशन किया जाये, तब अंडरफ्लो कंडीशन उत्पन्न होती है।  

3.) Peek:- To access/print top element of stack is called peek operation. This work is performed from top of the stack. if top=-1 it means stack is empty then peek operation cant be performed.
स्टैक में उपस्थित टॉप एलिमेंट को एक्सेस/प्रिंट करना, पीक ऑपरेशन कहलाता है। यह कार्य स्टैक के top पर किया जाता है। यदि  top=-1 अर्थात स्टैक खाली है, तब पीक ऑपरेशन नहीं किया जा सकता है।   

Example :-

No comments:

Post a Comment

Stack Data Structure, Push, Pop and Peek Operations , Applications of Stack

Stack is a linear data structure. It is collection of ordered data elements. It is also known as LIFO system (last in first out). It means i...