claude-3-5-haiku-20241022
- kreditů:
- 0.37729799999999997
- Čas generování:
- 8.71 s
The correct answer is B) Stack.
A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. This means that the last element added to the stack will be the first one to be removed.
Key characteristics of a stack include:
- Elements are added and removed from the same end, called the "top" of the stack
- Basic operations include:
- Push: Adding an element to the top of the stack
- Pop: Removing the top element from the stack
- Peek/Top: Viewing the top element without removing it
Real-world analogies for a stack include:
- A stack of plates, where you can only add or remove from the top
- A web browser's back button, which shows the most recently visited pages first
Common implementations of stacks include:
- Array-based stacks
- Linked list-based stacks
- Used in many algorithms like depth-first search, expression evaluation, and function call management in programming
In contrast:
- Queue follows First-In-First-Out (FIFO)
- Linked lists allow insertion and deletion from multiple points
- Hash tables are for key-value pair storage and retrieval