What is a data structure?
A data structure is a way of organising and storing data in memory so it can be used efficiently. Different structures are good at different jobs. An array is great for fast lookups by position, a linked list is great for frequent inserts, and a hash table is great for fast lookups by key. Choosing the right one is the difference between fast and slow code.
The core idea
Data by itself is just a pile of values. A data structure gives that data a shape so your program can find, add, and remove items quickly. Think of it like the difference between a messy drawer and a labelled filing cabinet.
Common examples
- Array: items in a row, fast access by index.
- Linked list: items linked by pointers, easy to insert and remove.
- Stack: last in first out, like a pile of plates.
- Queue: first in first out, like a line at a shop.
- Hash table: key to value lookups in near constant time.
- Tree and graph: for hierarchical and connected data.
Interviewers care less about the definition and more about whether you can pick the right structure for a problem. Practice saying which structure you would use and why, for example a hash map for counting frequencies.
Common follow up questions
Related interview questions
Want the full DSA guide?
Read every DSA concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the DSA guide All DSA questions