Stacks Flashcards
a linear data structure that follows the Last-In-First-Out (LIFO)principle.
Stacks
(T or F) in stacks the last element added to the stack is the first one to be removed.
True
(T or F) in stacks Insertion and deletion allowed only at one end (top)
True
adding an element to the top of the stack
Push
removing the topmost element from the stack
Pop
viewing the topmost element without removing it in stacks
Peek
the stack is full and push operation is attempted
Overflow state
the stack is empty and we attempt the pop operation
Underflow state
Stacks are used to evaluate arithmetic expressions, handle operator precedence, and perform in fix-to-postfix conversion.
Expression Evaluation
Stacks are used to implement undo functionality in text editors, software applications, and interactive environments.
Undo Operations
Stacks are utilized in algorithms that require backtracking, such as maze-solving and depth-first search.
Backtracking
Stacks play a role in __________________________, particularly in managing activation records during program execution.
Memory Management
Array-based
top is increased by 1
new element is placed in index top
Push
Array-based
top is decreased by 1
element at index top is taken out
Pop
Array-based
top is -1 means
stack is empty