Skip to content
Getting Digital

Data Structures and Algorithms

Also: DSA, algorithms, data structures, Big O, time complexity, hash table, binary search, coding interview

Data structures are the ways a program arranges data in memory (arrays, lists, hash tables, trees, graphs) and algorithms are the step-by-step procedures that work on them; together they decide whether an operation takes a millisecond or an hour as the data grows.

Assessment. A working developer needs a limited set of structures and algorithms: the ones that explain why a nested loop fails at ten thousand rows and why a dictionary lookup does not. That set should be learned until the growth rates are recognised on sight; the remainder, which technical-interview preparation has expanded considerably, can be learned when a problem or an interview requires it.

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.

StructureGood atCostly atEveryday form
Array or listIndex access, iterationInsert at the front, searchA list in Python, an array in JavaScript
Hash tableLookup, insert and delete by keyOrdered traversalA dict, a Map, an object used as a lookup
Stack and queueLast in first out; first in first outRandom accessUndo history; a job queue
TreeOrdered data, hierarchies, prefix searchKeeping it balancedA file system; a database index
GraphNetworks and dependenciesEverything is a traversalA 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.

In practice

  • The task: flag the customers in an export of 200,000 orders who also appear in a 50,000-row list of accounts in arrears.
  • The slow version: for each order, scan the arrears list. Ten billion comparisons; the script runs for hours.
  • The fast version: put the 50,000 account numbers in a set, then check each order against the set. 250,000 operations; the script finishes in seconds.
  • The lesson: nothing about the problem changed. The data structure did, and the growth rate with it.

Often confused with

Object-Oriented Programming (OOP)
Object orientation organises code around the things it models; data structures and algorithms decide how data is arranged and how steps are ordered for speed. A class can wrap a data structure, and an algorithm can live in a method, but the subjects are separate.
SQL
SQL describes a result and leaves the algorithm to the database, which chooses between a scan, an index tree search and a hash join on the developer's behalf. Knowing the structures explains why one query is fast and the next is not.

Key takeaways

  • →One question: how does cost grow with data? O(1), O(log n), O(n), O(n log n), O(n²) are the answers to recognise on sight.
  • →A hash table turns a scan into a lookup; a sorted structure turns a scan into a handful of steps. Most speed-ups are one of those two moves.
  • →Own a dozen structures and algorithms; learn the rest on demand.

Related concepts

  • RelatedPython

    The structures are built into the language and the usual practice ground.

  • RelatedSQL

    A query planner chooses between scan, index tree and hash join on the developer's behalf.

Where this concept sits in the field

Certifications that test this

Vendor exams whose syllabus covers this concept: facts, cost and a preparation path on each page.

FAQ

Do I need this to get a first developer job?
Enough to explain why nested loops are slow and when to use a dictionary, yes. The interview form, with tree problems solved on a whiteboard, depends on the employer: larger technology companies test it, most agencies and smaller firms do not.
Which language should I practise in?
The one you already write. Python is the usual choice because the structures are built in and the syntax is unobtrusive; CS50x deliberately starts in C so that memory and pointers are visible before Python hides them.
Is Big O the same as actual speed?
No. It describes how cost grows, not how long one run takes. An O(n) scan of a hundred items finishes before an O(1) lookup with a heavy setup; the notation matters once n is large enough for growth to dominate, which in practice means thousands of items and up.

Sources

The primary text this definition rests on. Read it before relying on this one.

  • Cormen, T. H., Leiserson, C. E., Rivest, R. L. and Stein, C., Introduction to Algorithms, 4th edition (MIT Press) (2022)
  • Sedgewick, R. and Wayne, K., Algorithms, 4th edition (Addison-Wesley) (2011)
  • Python Software Foundation wiki, TimeComplexity

Last reviewed 3 October 2026 · Getting Digital