Data Structure

A data structure is how you arrange information in memory, chosen to make the operations you'll do most often cheap. A plain list (array) is great for reading item number 5 instantly, but slow to search. A hash table finds any item by name in effectively one step, but keeps nothing in order. A tree keeps things sorted and searchable at once. A stack hands back the most recent item first; a queue, the oldest.

There's no best structure, only the best fit for what you need to do — which is why the choice of data structure and the choice of algorithm are really one decision. Pick the right container and a hard problem becomes easy; pick the wrong one and even a clever algorithm crawls.

hierarchy prerequisite related

See the full map →