[go: up one dir, main page]

0% found this document useful (0 votes)
36 views8 pages

Stack in Data Structures Class Notes

A stack is a linear data structure that follows the Last In First Out (LIFO) principle, allowing insertion and deletion only at the top. Basic operations include push, pop, peek, isEmpty, and isFull, and stacks can be implemented using arrays or linked lists. Stacks are widely used in applications such as expression evaluation, undo/redo operations, and function call management.

Uploaded by

905satheeshkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views8 pages

Stack in Data Structures Class Notes

A stack is a linear data structure that follows the Last In First Out (LIFO) principle, allowing insertion and deletion only at the top. Basic operations include push, pop, peek, isEmpty, and isFull, and stacks can be implemented using arrays or linked lists. Stacks are widely used in applications such as expression evaluation, undo/redo operations, and function call management.

Uploaded by

905satheeshkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Stack in Data Structures (Class

Notes)
Data Structures - Class Notes
Introduction to Stack

• Stack is a linear data structure


• Follows LIFO (Last In First Out) principle
• Insertion and deletion allowed only at one
end (top)
Basic Operations on Stack

• push(x): Insert element x at the top


• pop(): Remove and return top element
• peek()/top(): Return top element without
removing
• isEmpty(): Check if stack is empty
• isFull(): Check if stack is full (for fixed size)
Stack Representation

• Implemented using arrays or linked lists


• Array-based stack: fixed size
• Linked list-based stack: dynamic size
• Top pointer indicates current position
Applications of Stack

• Expression evaluation and conversion (Infix,


Postfix, Prefix)
• Undo/Redo operations in editors
• Backtracking algorithms (maze, puzzles)
• Function call management (recursion)
• Browser history navigation
Expression Conversion using Stack

• Infix → Postfix (Shunting-yard algorithm)


• Postfix evaluation using stack
• Prefix → Infix/Postfix conversions
• Parenthesis matching
Advantages & Limitations

• Simple to implement
• Efficient for LIFO operations
• Limited access (only top element accessible)
• Fixed size in array implementation may cause
overflow
Summary & Key Points

• Stack is LIFO data structure


• Supports push, pop, peek operations
• Implemented using arrays or linked lists
• Extensively used in compilers, recursion, and
algorithms

You might also like