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.
28 cards · basic cards · AI-written, checked twice. Edit anything.
- What is a stack?
- A linear data structure that follows Last-In-First-Out (LIFO) order
- What operation adds an element to the top of a stack?
- Push
- What operation removes and returns the top element of a stack?
- Pop
- What operation returns the top element of a stack without removing it?
- Peek (or top)
- What is the time complexity of push and pop operations on a stack?
- O(1)
- What real-world scenario is commonly modeled by a stack?
- The undo feature in a text editor, or a browser's back button history
- What is stack overflow, in the context of function calls?
- 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?
- A call stack
- What is a common use of a stack in checking balanced parentheses?
- Pushing opening brackets and popping/matching them against closing brackets
- What is a queue?
- A linear data structure that follows First-In-First-Out (FIFO) order
- What operation adds an element to the back of a queue?
- Enqueue
- What operation removes and returns the element at the front of a queue?
- Dequeue
- What is the time complexity of enqueue and dequeue operations on a well-implemented queue?
- O(1)
- What real-world scenario is commonly modeled by a queue?
- People waiting in line, or tasks waiting to be processed in order
- What is a circular queue?
- A queue implemented with a fixed-size array that wraps around to reuse freed space