Algorithms and Data Structures

Suppose you have ten names and need to find one. You can read the list from top to bottom. That will probably be enough. Now suppose you have a million names and need to search them thousands of times a day. Reading from the top each time may still give the right answer, but it may be a poor way to do the job. You could sort the names, build an index, or keep them in a structure designed for lookup. Each choice makes some tasks easier and others harder.

This course is about understanding those choices. An algorithm is a method for solving a problem. A data structure is a way of keeping data so a method can use it. The two are closely connected. A good method for a sorted list may fail on an unsorted one. A structure that finds a name quickly may take more space or more work to update. Rather than memorize which structure is “best,” you will learn to ask what the program needs to do and what each choice costs.

We begin with small algorithms you can trace by hand. Sorting gives us a place to see how a method works and to ask why it produces the right answer. Then we look at what happens when the input grows. We will split problems into parts, combine answers, and sometimes make a random choice. The purpose of counting work is practical: it helps us judge whether a method that feels quick on four items will still make sense on four million.

From there we move through the structures that make larger programs possible: arrays, linked lists, stacks, queues, hash tables, search trees, heaps, and structures built for large indexes or changing groups. We will not treat them as a collection of shapes to remember. For each one, we will put data in it, change that data, look something up, and see where the work goes. A diagram can show what a pointer changes. A short program can show what happens when the structure is empty or contains a duplicate.

Some problems are less about storing data than about finding a way through many possible answers. Dynamic programming saves work by reusing answers to smaller problems. A greedy method makes one promising choice at a time, but we have to ask when that choice is safe. Amortized analysis explains why an operation that is occasionally expensive can still be cheap across a long sequence of operations. These ideas matter because a program runs many operations, not just one.

Graphs let us describe connections: roads, dependencies, computer networks, and possible assignments. We will explore a graph, find routes, connect places at low total cost, and see how flow and matching problems arise. The final part of the course opens the door to parallel and online algorithms, matrices, optimization, the fast Fourier transform, number theory, text search, machine learning algorithms, NP-completeness, and approximation. These are large subjects. Here you will meet the central question in each one and work through a representative idea. The aim is a sound first understanding, not the claim that one lesson makes you an expert.

The path follows all 35 chapters of Cormen, Leiserson, Rivest, and Stein’s Introduction to Algorithms, fourth edition. The book is a reference for what we cover and for technical accuracy. This course uses its own explanations, examples, diagrams, code, and exercises. It takes a lighter route through the material: concrete examples come before formal proofs, and harder mathematics is introduced when we need it. We will still name the assumptions a method depends on and say when a simple explanation leaves something out.

You should be comfortable writing a small program with variables, loops, functions, and lists before you begin. The code examples use Python, alongside pseudocode when the idea is clearer without a programming language. Comments inside code blocks explain the steps; you can hide them to see the code alone. You will also find worked traces, diagrams, and questions with answers. It helps to pause before each answer, predict what will happen, and test your prediction. If you have just finished Introduction to Computing, a little more practice writing small programs will make this course easier to use.

You can follow the lessons in order or open the topic that is causing trouble today. Each page introduces its own example, states the background it needs, and links to related explanations. The worked cases show why a method works and what can go wrong when its assumptions change. Try the questions before reading their answers; being able to follow an explanation and being able to use it are different stages of learning.

The draft contains a lesson for each of the book’s 35 chapters, followed by four mathematical reference lessons. It still needs technical, code, and page review before publication. As you read, keep asking three questions: What problem are we solving? Why does this method work? What changes when the input grows?

Image preview

Fit