0% found this document useful (0 votes)
6 views1 page

Understanding Stack Data Structure

A stack is a linear data structure that operates in a Last In First Out (LIFO) manner, allowing insertions and deletions only at the top. Key operations include PUSH for adding elements, POP for removing elements, and Peek for inspecting the top element. Stacks have various applications such as expression evaluation, syntax parsing, backtracking, and function call management.

Uploaded by

Manvi Gupta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Understanding Stack Data Structure

A stack is a linear data structure that operates in a Last In First Out (LIFO) manner, allowing insertions and deletions only at the top. Key operations include PUSH for adding elements, POP for removing elements, and Peek for inspecting the top element. Stacks have various applications such as expression evaluation, syntax parsing, backtracking, and function call management.

Uploaded by

Manvi Gupta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter -2 Stack

A stack is a linear structures implemented in LIFO (Last In First Out) manner where
insertions and deletions are restricted to occur only at one end – stack’ s top. LIFO means
element last inserted would be the first one to be deleted.

1. Data can only be removed from the top (pop), i.e., the element at the top of the stack. The
removal of element from a stack is technically called POP operation.
2. A new data element can only be added to the top of the stack (push). The insertion of
element in a stack is technically called PUSH operation
3. Peek:Refers to inspecting(printing) the value at the stack’s top without removing it; it is
also sometimes referred as inspection.
4. Underflow:Refers to situation (ERROR) when one tries to pop/ delete an item from an
empty stack. That is, stack is currently having no item and still one tries to pop an item.
5. Overflow:Refers to situation (ERROR) when one tries to push an item in stack that is full.
This situation occurs when the size of the stack is fixed and cannot grow further or there is
no memory left to accommodate new item.
Applications of Stack:
• Expression Evaluation: It is used to evaluate prefix,postfix and infix expressions.
• Expression Conversion: It can be used to convert oneform of expression(prefix,postfix or infix)
to one another.
• Syntax Parsing: Many compilers use a stack for parsingthe syntax of expressions.
• Backtracking: It can be used for back traversal of stepsin a problem solution.
• Parenthesis Checking: Stack is used to check theproper opening and closing of parenthesis.
• String Reversal: It can be used to reverse a string.
• Function Call: Stack is used to keep information aboutthe active functions or subroutines.

You might also like