Data Structures, unit: Stacks and Queues. Core concepts, terminology, and worked-example cues a college student meets for this unit, building on prior units without repeating them. Front: a term, concept, or short problem cue. Back: the definition, explanation, or answer.
38 cards · basic cards · AI-written, checked twice. Edit anything.
- What is a stack?
Show answer
A linear data structure that follows Last-In-First-Out (LIFO) order
- What operation adds an element to the top of a stack?
Show answer
Push
- What operation removes and returns the top element of a stack?
Show answer
Pop
- What operation returns the top element of a stack without removing it?
Show answer
Peek (or top)
- What is the time complexity of push and pop operations on a stack?
Show answer
O(1)
- What real-world scenario is commonly modeled by a stack?
Show answer
The undo feature in a text editor, or a browser's back button history
- What is stack overflow, in the context of function calls?
Show answer
Running out of stack memory, often due to excessive or infinite recursion
- What data structure is used behind the scenes to manage function calls in most programming languages?
Show answer
A call stack
- What is a common use of a stack in checking balanced parentheses?
Show answer
Pushing opening brackets and popping/matching them against closing brackets
- What is a queue?
Show answer
A linear data structure that follows First-In-First-Out (FIFO) order
- What operation adds an element to the back of a queue?
Show answer
Enqueue
- What operation removes and returns the element at the front of a queue?
Show answer
Dequeue
- What is the time complexity of enqueue and dequeue operations on a well-implemented queue?
Show answer
O(1)
- What real-world scenario is commonly modeled by a queue?
Show answer
People waiting in line, or tasks waiting to be processed in order
- What is a circular queue?
Show answer
A queue implemented with a fixed-size array that wraps around to reuse freed space