The subject answers one question: how does the cost of an operation grow with the size of the data? Big O notation is the vocabulary. Finding an item by scanning a list is O(n), proportional to the length; finding it in a hash table is O(1) on average, the same cost whether the table holds ten entries or ten million; finding it in a sorted array by binary search is O(log n), a handful of steps for a million items. A loop that compares every item with every other is O(n²), which is why a report that ran in a second on test data takes an hour in production. Python's own documentation lists these costs for its built-in list, dictionary and set, and the same table exists for every language.
| Structure | Good at | Costly at | Everyday form |
|---|---|---|---|
| Array or list | Index access, iteration | Insert at the front, search | A list in Python, an array in JavaScript |
| Hash table | Lookup, insert and delete by key | Ordered traversal | A dict, a Map, an object used as a lookup |
| Stack and queue | Last in first out; first in first out | Random access | Undo history; a job queue |
| Tree | Ordered data, hierarchies, prefix search | Keeping it balanced | A file system; a database index |
| Graph | Networks and dependencies | Everything is a traversal | A road map; a build dependency order |
The algorithms worth owning are the ones attached to those structures: sorting (and knowing the library sort is O(n log n) and already written), binary search, breadth-first and depth-first traversal of a tree or graph, and the habit of trading memory for time by building a lookup table once. A relational database applies the same ideas on the developer's behalf, which is why an index turns a table scan into a tree search and why SQL performance is largely a question of which structure the query planner could use. The standard textbooks, Cormen and colleagues' Introduction to Algorithms and Sedgewick and Wayne's Algorithms, go far beyond this; the dozen above is what a working developer reaches for weekly.
Where the subject is examined
Harvard's CS50x builds arrays, linked lists, hash tables and tries in C before moving to Python, and the freeCodeCamp JavaScript certification, which carried the words algorithms and data structures in its title until its current edition, grades the same ideas through coding exercises. Vendor cloud exams do not test the subject directly; technical interviews at larger employers do.
