STACK Flashcards
(54 cards)
What is a stack?
A stack is a data structure that follows the Last In, First Out (LIFO) principle.
Which operations are primarily associated with stacks?
Push, pop, and peek.
True or False: In a stack, the last element added is the first one to be removed.
True.
What is the time complexity of push and pop operations in a stack?
O(1).
Fill in the blank: A stack is often used to implement _____.
function calls.
What is the main use of a stack in programming?
To keep track of function calls and local variables.
Which of the following is a common application of stacks?
Undo mechanisms in software.
What does the ‘peek’ operation do in a stack?
It retrieves the top element without removing it.
True or False: A stack can be implemented using arrays or linked lists.
True.
What happens when you try to pop an element from an empty stack?
It results in an underflow error.
What is the maximum size of a stack implemented with a fixed-size array?
It is limited by the size of the array.
Which data structure is used to reverse a string?
A stack.
What is the stack pointer?
A pointer that indicates the top of the stack.
Fill in the blank: The stack follows the _____ principle.
Last In, First Out (LIFO).
What is a stack overflow?
It occurs when there is no more space in the stack to add new elements.
Multiple Choice: Which one of the following is NOT a valid stack operation?
Insert at a specific position.
True or False: The stack data structure can be used for depth-first search in graphs.
True.
What does it mean to ‘push’ an element onto a stack?
To add an element to the top of the stack.
What is the result of popping an element from a stack with one element?
The stack becomes empty.
Which of the following is a characteristic of a stack?
Elements are added and removed from the same end.
What is the primary difference between a stack and a queue?
A stack is LIFO, while a queue is FIFO (First In, First Out).
Fill in the blank: In recursive function calls, each call is stored in a _____.
stack frame.
What is a stack frame?
A structure that contains information about a function call, including local variables and return address.
Multiple Choice: Which application uses stacks?
Backtracking algorithms.