Data Structures & Algorithms
Data structures and algorithms, taught for data science and AI — not for whiteboard trivia. From Big-O and binary search to trees, graphs, dynamic programming, and the probabilistic structures (Bloom filters, MinHash-LSH) that power real dedup and retrieval. Python throughout, every idea animated.
- Chapter 01
Foundations
4 lessons - 01 Why DSA for Data Science The same correct code can take three hours or three seconds — and the difference is usually the data structure you chose, not the language.
- 02 Big-O & Complexity How to tell whether an algorithm will still work when your data is 1,000× bigger — and what best, worst, and average case really mean.
- 03 Recursion & the Call Stack A function that calls itself — what that means, what happens in memory when it does, and how memoisation turns exponential recursion into linear work.
- 04 Python Built-ins & Their Cost Every built-in operation hides a Big-O. Knowing a handful of them is most of what it takes to write fast Python.
- Chapter 02
Searching
3 lessons - 05 Linear Search The simplest search there is — look at each item in turn until you find what you want. Slow when the data is huge, but often exactly right.
- 06 Binary Search Search a sorted array in O(log n) — halve the range with every comparison, so a million items need only about twenty looks.
- 07 Search Patterns The halving idea reaches far beyond sorted arrays — counting duplicates, rotated arrays, 2-D matrices, and searching the answer itself.
- Chapter 03
Sorting
4 lessons - 08 Bubble, Insertion & Selection The three elementary O(n²) sorts — slow on big data, but they lay bare the cost model that every faster algorithm is built to beat.
- 09 Merge Sort & Divide-and-Conquer Split the problem until it is trivial, then rebuild the answer — how merge sort reaches O(n log n) in every case and why that makes it the bedrock…
- 10 Quicksort & Partitioning How quicksort picks a pivot, splits the array in a single pass, and recurses — plus why a bad pivot turns O(n log n) into O(n²), and how real libra…
- 11 Timsort, Stability & sorted() You will never hand-write a sort in production — but you need to know exactly what Python's sorted() and list.sort() do, because it quietly shapes…
- Chapter 04
Core Data Structures
4 lessons - 12 Arrays vs Linked Lists Two ways to hold a sequence — one as a single contiguous block, the other as scattered nodes joined by pointers. The choice reshapes the cost of ev…
- 13 Stacks, Queues & Deques Two simple ordering rules — last-in-first-out and first-in-first-out — quietly power the call stack, undo history, BFS, and bracket checking. Plus…
- 14 Hash Tables & Dicts The most important structure in data work — how a hash function turns a key straight into an array index, why lookup is O(1) on average, and what h…
- 15 Heaps & Priority Queues How a heap keeps the best item always on top — O(1) peek, O(log n) push and pop — and why it is the natural priority queue for Dijkstra, beam searc…
- Chapter 05
Trees
4 lessons - 16 Trees & Traversals How trees model hierarchies — and the four canonical ways to walk every node, each powered by a queue or a stack.
- 17 Binary Search Trees A tree that keeps the binary-search rule alive — left < node < right — so every search and insert follows one root-to-leaf path instead of scanning…
- 18 Tries (Prefix Trees) A tree where the path from the root spells a string — giving O(L) insert and lookup that never depends on how many words you store, and making pref…
- 19 Balanced Trees & B-Trees Why a plain BST can collapse to O(n), how self-balancing trees fix it with rotations, and why databases reach for B+-trees instead of binary trees…
- Chapter 06
Graphs
4 lessons - 20 Graph Representations How to store a graph in code — adjacency list versus adjacency matrix — and how to pick the right one for the job.
- 21 Graph Traversal: BFS & DFS How to visit every node in a graph — BFS spreading outward ring by ring, DFS plunging deep before backtracking — and which to reach for when.
- 22 Shortest Paths (Dijkstra) BFS finds the path with fewest hops; Dijkstra finds the path with least total cost. Learn relaxation, the min-heap frontier, and why weights must b…
- 23 Graphs for ML & Knowledge Graphs How the graph ideas from this chapter — nodes, edges, BFS, adjacency — quietly power knowledge graphs, node embeddings, GNNs, and GraphRAG in produ…
- Chapter 07
Algorithmic Techniques
5 lessons - 24 Two Pointers & Sliding Window Stop re-scanning. Keep one or two indices moving forward and reuse the work you already did — the pattern that turns O(n²) into O(n) for a surprisi…
- 25 Divide & Conquer A three-step pattern that turns a hard problem into smaller copies of itself — and the reasoning for why it runs so efficiently.
- 26 Greedy Algorithms Solving optimization problems by always taking the best option available right now — and knowing when that local optimism is provably correct versu…
- 27 Dynamic Programming Turning exponential recursion into polynomial time by solving each subproblem exactly once — the technique behind spell-check, sequence alignment,…
- 28 Backtracking Searching a combinatorial space by building solutions one piece at a time and pruning dead branches early — the engine behind N-Queens, Sudoku, and…
- Chapter 08
DSA for Data Science
4 lessons - 29 When O(n²) Kills Your DataFrame How accidental quadratic complexity sneaks into real data pipelines — and the hash-based patterns that quietly fix it.
- 30 Vectorization vs Loops Why two O(n) algorithms can differ by 50-100× in wall time — and how NumPy pushes the loop into compiled C over a tight block of typed memory.
- 31 Sampling & Reservoir Sampling How to draw a perfectly uniform random sample of k items from a stream too big for memory — in one pass, O(n) time, O(k) space.
- 32 Bloom Filters, HyperLogLog & MinHash-LSH Trade a little accuracy for enormous savings in space and time — the probabilistic structures every data engineer should keep in their toolkit.
- End of section 0 / 32 complete
Make it stick — pass every quiz.
Each lesson has a short quiz at the bottom. Passing the quiz is what marks the lesson complete and counts toward your certificate.
Section complete 32 / 32 lessonsNice work — you finished Data Structures & Algorithms.
Certificates are earned per learning path, not per section. Here's where this section takes you:
Pick a learning path to start working toward a certificate.
Data Structures & Algorithms — frequently asked questions
Straight answers to the questions people ask most about data structures & algorithms.
How much DSA do I need for data science and ML?
The practical core: Big-O intuition to reason about cost, hash maps and sets for fast lookups and dedup, sorting and binary search, and a feel for when an O(n²) approach won't scale. You rarely implement exotic algorithms, but understanding complexity is what keeps data pipelines fast.
What is Big-O notation, simply?
Big-O describes how an algorithm's time or memory grows as the input grows, ignoring constants. O(n) doubles when the input doubles; O(n²) quadruples; O(log n) barely grows. It's the tool for predicting whether code will still be fast at 10× or 1000× the data.
When should I use a hash table?
Use a hash table (dict or set in Python) whenever you need fast lookups, membership tests, counting, or deduplication — it offers average O(1) access. It's the workhorse behind grouping, joins, and 'have I seen this before' checks across data work.
What's the difference between O(n log n) and O(n²)?
O(n log n) is the speed of good sorting algorithms and scales to millions of items; O(n²) compares every pair and becomes painfully slow past a few thousand. Turning a nested-loop O(n²) approach into a sort- or hash-based one is one of the highest-leverage optimisations.
What are Bloom filters and HyperLogLog used for?
They're probabilistic structures that trade a little accuracy for huge memory savings at scale. A Bloom filter answers 'have I probably seen this?' without storing every item; HyperLogLog estimates the count of distinct items in a stream using tiny memory. Both power real-world dedup and analytics.