What is a data structure?
A data structure is a way of storing and organizing data so it can be used efficiently. Two broad families:
- **Linear*: items in a sequence (arrays, lists, stacks, queues).
- **Hierarchical*: items in a tree-like or network layout (trees, graphs).
Linear: A - B - C - D
Hierarchical:
A
/ \
B C
Picking the right one is a balance between how fast you read, add, or delete data.
Time complexity in plain words
We measure how a structure's speed scales as data grows. Think of it as "how many things do I have to check?"
| Structure | Find one item |
|---|---|
| Array (unsorted) | check many |
| Hash map | jump straight to it |
10 items -> both are fast
10,000 -> hash map wins big
1,000,000 -> the difference is huge
Big structures save the biggest wins, which is why programmers care.