Save
MIDTERM_2ND SEM.1
Data Structure & Algorithm Analysis
STACKS
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
rein
Visit profile
Cards (15)
Stack
is linear data structure that follows LIFO principle which means that the last element added to the stack is the first one to be removed.
Push
adds an element to the top of the
stack
Pop
removes
the
top
element of the stack.
Peek (Top)
returns
the
top
element without
removing
it.
isEmpty
checks
if the stack is
empty.
Expression evaluation
used in
compilers
to evaluate
expressions
like (a+b) * c
Undo/Redo
Functionality

applications like text editors use
stacks
to track changes
Function Call Management
when a
function
is called, its execution
details
are stored in a
stack
.
Backtracking
used in solving problems like mazes, navigating webpages (browser back button), and recursion.
STACK
Used when
elements
are
need
to be
managed
in
reverse
order
Stacks
are widely used in programming including:
Expression evaluation
Undo/Redo Functionality
Function Call Management
Backtracking
Expression evaluation
used in
compilers
to evaluate expressions like
(a+b)
* c
Undo/Redo Functionality
applications
like text editors use
stacks
to track changes
Function Call Management
when a
function
is called, its execution details are stored in a
stack
.
Backtracking
used in solving problems like
mazes
, navigating webpages (browser back button), and
recursion
.