Data Structures
Prerequisites: Arrays, Objects
A data structure is a particular way of organizing data so certain operations (searching, inserting, ordering) are fast and convenient. Arrays and objects are the two you already know; a few more show up constantly:
- Stack — add and remove from the same end only (like a stack of plates — you take the top one off first).
- Queue — add at the back, remove from the front (like a checkout line — first in, first served).
- Set — a collection with no duplicates, optimized for "is this value in here?"
- Map (also called a dictionary/hash map) — like an object, but built specifically for very fast lookups by key.
Choosing the right data structure for a problem is usually more important than choosing the "cleverest" algorithm.