What data structures and algorithms solve
A data structure organizes data; an algorithm is a defined procedure for transforming or inspecting it.
Learning objectives
- Distinguish representation from procedure.
- Choose operations before choosing a structure.
The central question
Before coding, ask what the program must do often: find by position, find by name, add at the front, remove the most recent item, or visit connected items. A representation that makes one operation cheap can make another costly.
Example
A waiting line needs first-in, first-out removal, so a queue matches its rule. Undo history needs the most recent action first, so a stack matches it. The names describe behavior, not just containers.
Common mistakes
- Do not choose a structure because it is familiar before listing operations and constraints.
- Do not discuss “fast” without saying which operation, which input size, and which model.