Neural Sync Active
Data Structures
Registry Synced
Data Structures
107 words
1 min read
Data Structures
Data structures are shapes for information.
Common shapes
- List: ordered sequence.
- Dictionary: lookup by key.
- Stack: last in, first out.
- Queue: first in, first out.
Choose by operation
Ask what the program needs to do most often:
- Need order? Use a list.
- Need fast lookup by name or id? Use a dictionary.
- Need undo behavior? Use a stack.
- Need process-in-arrival-order behavior? Use a queue.
Practice
For each problem, write the operation first:
I need to look up a student by roll number.
That points to a dictionary before you write any code.