Data Structures & Algorithms

Arrays, hash maps, linked lists, stacks, queues, recursion, searching, sorting, trees, heaps, graphs, and dynamic programming in TypeScript — tied to where you meet them at work, and ready for technical interviews.

Every program is a pile of data plus a set of steps for working with it. Data structures are the ways we arrange the data, and algorithms are the steps. Pick the right pair and a page that crawls with 100,000 rows becomes instant. Pick the wrong pair and no amount of faster hardware will save you. These are also the topics technical interviews return to, because they show how you think when a problem has no obvious answer.

This series teaches them in TypeScript, and always with a "where do I meet this at work?" angle. Arrays and hash maps are behind every list and lookup table. Stacks power undo history and the call stack. Queues run background jobs. Trees are the DOM and the file system. Graphs are maps, social networks, and dependency lists. Heaps schedule tasks. You will build each of them yourself, so you understand what the built-in versions cost.

The first chapters cover the everyday structures: arrays and strings, hash maps and sets, linked lists, stacks and queues. The middle chapters cover the core techniques: recursion, searching, and sorting. The later chapters cover trees, heaps, graphs, tries and union-find, and finally greedy algorithms and dynamic programming. The last chapter turns it into a repeatable method for attacking an unfamiliar interview problem.

You won't just read about it. Across the series you build algolab, a small TypeScript toolkit that runs in Node.js. Each chapter adds one module with a few tests: a hash map, a linked list, a stack and queue, a sorting collection, a binary search tree, a priority queue, a graph with BFS and Dijkstra, a trie, and more. By the end you have a tested library you wrote yourself.

You need to be comfortable with JavaScript and a little TypeScript from JavaScript & TypeScript Fundamentals, and with Big-O notation from Math for Programmers. You need Node.js (the LTS version) and a code editor such as Visual Studio Code. Nothing costs money.

  1. 01Why Data Structures and Algorithms MatterWhy the way you arrange data decides how fast your code runs: a Big-O refresher, a first benchmark of Array.includes against Set.has, and the setup of the algolab TypeScript project with its first bench module.
  2. 02Arrays and StringsHow arrays and strings sit in memory, what push, pop, shift, unshift and splice really cost, and three core techniques (two pointers, sliding window, prefix sums), adding an arrays module to algolab.
  3. 03Hash Maps and SetsHow hashing gives O(1) lookups, how collisions are handled with chaining, frequency counting, two-sum, anagrams, and Map versus Object, adding a HashMap class and helper functions to algolab.
  4. 04Linked ListsNodes and pointers, singly and doubly linked lists, array versus list trade-offs, reversing, cycle detection with fast and slow pointers, finding the middle, and merging sorted lists — used to build a LinkedList class for algolab.
  5. 05Stacks and QueuesLast-in-first-out stacks, first-in-first-out queues, undo history, the call stack, balanced brackets, a queue on a linked list, a circular buffer, and a queue from two stacks — used to build Stack, History, Queue and CircularBuffer for algolab.
  6. 06RecursionBase cases, the call stack, stack overflow, memoization, recursion versus loops, and an introduction to backtracking with subsets, permutations, and parentheses — used to build a recursion module for algolab.
  7. 07SearchingLinear search, binary search, off-by-one pitfalls, lower and upper bound, rotated arrays, and binary search on the answer — used to add searching.ts to algolab.
  8. 08SortingBubble, insertion, merge, and quick sort, stability, the Array.sort default-string pitfall, comparators, counting sort, and a benchmark — used to add sorting.ts to algolab.
  9. 09Trees and Binary Search TreesTree vocabulary, the DOM and file system as trees, depth-first (preorder, inorder, postorder) and breadth-first traversal, binary search tree insert, search and delete, height and balance, and classic interview problems — used to build a tree module for algolab.
  10. 10Heaps and Priority QueuesPriority queues, the array-backed binary heap, sift up and sift down, heap sort, top-K, task scheduling, running median, and merging sorted lists — used to build a PriorityQueue for algolab.
  11. 11GraphsVertices and edges, directed and weighted graphs, adjacency lists versus matrices, BFS, DFS, shortest paths, connected components, cycle detection, topological sort, and Dijkstra's algorithm — used to build a Graph class for algolab.
  12. 12Tries and Union-FindPrefix trees for autocomplete, union-find with path compression and union by rank for grouping, connected components and redundant-edge detection — used to add a Trie and a UnionFind to algolab.
  13. 13Greedy and Dynamic ProgrammingGreedy choices (interval scheduling, coins), dynamic programming (Fibonacci, climbing stairs, coin change, knapsack, longest common subsequence), top-down versus bottom-up, and how to spot DP — used to add greedy.ts and dp.ts to algolab.
  14. 14Putting It TogetherA pattern cheat sheet for choosing a structure or technique, a seven-step interview method with a worked example, and a final algolab index.ts that exports every module — plus where to go next.