DATA STRUCTURE: STACK Flashcards
a linear data structure that follows the Last-In-First-Out (LIFO)
principle.
STACKS
the last element added to the stack
is the first one to be removed.
• Insertion and deletion allowed only
at one end (top)
STACKS OPERATION
adding an element to the top of the stack
Push (insertion)
STACKS OPERATION
removing the topmost element from the stack
Pop (deletion)
STACKS OPERATION
viewing the topmost element without removing
it
Peek
the stack is full and push operation is
attempted
Overflow state
the stack is empty and we attempt the pop
operation
Underflow state
APPLICATIONS AND USE CASES OF STACKS
Stacks are used to evaluate arithmetic expressions, handle operator precedence, and perform infix-to-postfix
conversion.
Expression Evaluation
APPLICATIONS AND USE CASES OF STACKS
Stacks are used to implement undo functionality in text
editors, software applications, and interactive environments.
Undo Operations
APPLICATIONS AND USE CASES OF STACKS
Stacks are utilized in algorithms that require backtracking,
such as maze-solving and depth-first search.
Backtracking
APPLICATIONS AND USE CASES OF STACKS
Stacks play a role in memory management, particularly in managing activation records during program execution.
Memory Management
a linear data structure that follows the First-In-First-Out (FIFO) principle.
QUEUES
first element added is the first one to be
removed
• It represents a collection of elements in
which elements are added at one end
(rear) and removed from the other end
(front).
Queues
adds an element to the rear (end) of the queue. The
newly added element becomes the last one in the
queue.
queues operations Enqueue (insertion)
removes the element from the front of the queue. The
next element in the queue becomes the new front.
Dequeue (deletion)