12 Data Structures You Use Every Day
Algorithms
- Dynamic Programming
Spell checkers measure how far your typo is from real words by computing the edit distance, the fewest insertions, deletions and swaps needed to turn one word into another. That table of smaller answers is classic dynamic programming.
- Arrays
A digital photo is a grid of pixels.
- Graphs
Flight search treats airports as vertices and direct flights as edges. Finding a trip with connections is a path search through that graph.
- Breadth First Search
Professional networks group people by how many introductions away they are. First degree connections are one hop away, second degree are two hops away, which is exactly the order BFS visits them.
- Sorting Algorithms
Game leaderboards keep millions of scores in order so the top players appear first.
- Linked Lists
A music player's queue keeps a pointer to the previous and next song, so skipping back and forth or inserting a song in the middle never shifts the rest of the queue.
- Hash Tables
Your phone's contacts app looks names up in a hash table, so finding a number takes the same time whether you have ten contacts or ten thousand.
- Topological Sort
Course planners use topological sorting to order classes so that every prerequisite comes before the classes that need it.
- Trees
Every web page is a tree. The browser's DOM nests elements inside elements, and rendering or searching the page walks that tree.
- Heaps
Operating systems pick the next process to run from a priority queue, so urgent work like handling a key press jumps ahead of background jobs.
- Dijkstra's Algorithm
Navigation apps find the quickest route by treating intersections as vertices and roads as weighted edges, where the weight is the expected travel time.
- Binary Search
When an outage starts, engineers search sorted logs by timestamp. Halving the range each time finds the first error among millions of lines in about twenty checks.