← Study Notes Programming Fundamentals


Programming Fundamentals

Algorithms & Data Structures

The vocabulary of computation: arrays, hash maps, trees, graphs, heaps and the algorithms that traverse them. Choosing the right structure decides whether an operation is constant or linear time — a hash map for lookups, a heap for priorities, a graph for relationships. It is the foundation every performance decision and coding interview rests on.


Purpose

Data structures are the shapes data can take in memory — arrays, hash maps, linked lists, trees, graphs, heaps — and algorithms are the recipes that operate on them: searching, sorting, traversing. Together they form the vocabulary of computation: every feature you build is ultimately a choice about how data is organised and walked.

When to Use It

You reach for a hash map for constant-time lookups, a heap for always-take-the-smallest scheduling, a tree for ordered data and range queries, and a graph for anything shaped like a network — routes, social links, recommendations. Databases, caches and queues are these same structures industrialised.

They are also the shared language of coding interviews, precisely because they reveal how a candidate reasons about cost.

Trade-offs

Every structure trades something: a hash map gives O(1) average lookups but no ordering; a balanced tree keeps order at O(log n); an array is compact and cache-friendly but expensive to grow in the middle. Choosing wrong rarely breaks correctness — it breaks performance, and usually only once real data volumes arrive.

Implementation

In practice you use the standard library's implementations — Map, Set, arrays, sorted structures — and your job is knowing the cost of each operation and picking by the dominant access pattern. When performance matters, confirm with a benchmark on realistic data rather than intuition.