14 weeks · Python · from the basics to Big-O

Algorithm Analysis
with Python

Two programs can give exactly the same answer, on exactly the same computer, and one can finish before you blink while the other runs until next Tuesday. This course is about noticing that difference, measuring it, naming it, and making better choices because of it — building the Python you need as you go.

Starts from "what is a program?" Python 3 in Google Colab 2–3 hours per week Weeks 1–14

01What this course is

Many algorithm courses open with proofs and assume you already program fluently. This one starts from working code and measurement. Weeks 1–4 build the slice of Python the subject needs — printing, variables, loops, lists — so nobody is left behind; from week 5 onward every new idea is introduced the same way: guess, measure, explain, name. If you already program, skim the first weeks and start at week 5.

By the end you will not be a software engineer, and that is fine. You will be someone who can look at two ways of doing a job and say, with evidence, "this one gets slower much faster than that one, and here is why." That skill transfers to spreadsheets, lab data, business processes and everyday decisions — it is not really about Python at all.

Who this is for

Students in any field who are early in their programming; researchers who inherited a script that is "too slow"; anyone curious about why software gets sluggish exactly when the data gets interesting. No mathematics beyond multiplication and a willingness to look at a graph.

02What you will be able to do

Read a program as steps

Take any small piece of code and count the work it does, instead of trusting your gut.

Measure honestly

Time code with repeats, plot time against input size, and know when a measurement is lying to you.

Speak Big-O

Recognise O(1), O(log n), O(n), O(n log n) and O(n²) in code you wrote yourself, and say what each means in plain words.

Pick the right container

Know when a list is the wrong tool and a set or dictionary makes a program a thousand times faster.

Spot the classic traps

Recognise the handful of everyday patterns that quietly turn a fast program into a slow one.

Defend a choice

Produce a short report: here is the problem, here are two approaches, here is the measurement, here is my recommendation.

03How a week works

Every week page follows the same shape, so you always know where you are:

  1. The big question — one sentence at the top of the page. Everything that week answers it.
  2. Plain-language explanation — with an everyday analogy before any code appears.
  3. Code you can run — short, complete, copy-paste into Colab. Never more than ~15 lines at a time.
  4. Predict, then run — you write down your guess before executing. Being wrong is the useful part.
  5. Try it yourself — small tasks with hints and full solutions hidden behind a click.
  6. Self-check quiz — instant feedback, no grades, unlimited attempts.
  7. Homework — one deliverable per week, usually a notebook plus five sentences of interpretation.
  8. Chapter problem set — a batch of exercises from Skiena's Algorithm Design Manual (Ch. 2), matched to the week and fully worked out at this course's level. By week 14 the whole chapter is solved. Harder proof-style or interview problems are marked ★ optional challenge — worth reading, never required. Every one of them is also worked out, even more simply, in the Skiena Chapter 2 solutions companion (a printable booklet).
The one rule

Never let a code block go by without running it. Reading about running time is like reading about swimming. The whole course is built around a stopwatch and a plot, and neither works from the sofa.

04Tools you need

ToolWhyCost / setup
Google ColabRuns Python in a browser tab. Nothing to install.Free, needs a Google account
A browserThese pages, and Colab.You have one
Paper or a text fileWriting predictions down before running code. This is not optional.Free

Nothing in this course needs a fast computer. A slow laptop is arguably a better teacher: the differences show up sooner.

05The 14 weeks

The first four weeks are pure "learn just enough Python". The last ten are the actual subject. If you already program a little, skim weeks 1–4 and start at week 5.

Phase 1 · Thinking in steps
Phase 2 · Measuring for real
Phase 3 · The language of growth
Phase 4 · Choosing well

06Assessment (suggested)

ComponentWeightWhat it is
Weekly homework (12 × )36%One notebook per week; graded pass / redo / good.
Self-check quizzes4%Completion only — they exist to catch confusion early.
Midterm (week 8)25%Read short code, count the steps, name the growth, justify in one sentence each.
Final project (weeks 12–14)35%Two approaches to one problem, benchmarked, plotted, and recommended in a two-page report.

There is no closed-book memorisation of complexity tables. Every table you would need is on these pages; the exam asks you to use it.

07The final project

Pick any small task with real data — searching a list of student records, counting words in a book, matching two spreadsheets, de-duplicating a mailing list. Then:

  1. Solve it the obvious, first-thing-that-comes-to-mind way.
  2. Solve it a second way using something you learned after week 9.
  3. Benchmark both at four input sizes and plot the two curves on one figure.
  4. Name the growth of each in Big-O and say why the curves look the way they do.
  5. Write two pages: problem, approaches, evidence, recommendation, one honest limitation.
Grading emphasis

The faster program does not automatically win. A project that measures carefully, explains an unexpected result and admits what it could not test scores higher than one that is fast but hand-waves.

09For mechatronics students: the engineering payoff

This course is taught in a Mechatronics Engineering department, and that is no accident. In a robot or a controller an algorithm must not only be correct — it must finish before the next sensor sample arrives, on a chip with kilobytes of memory. The engineering capstone turns every week of this course into the machines you will actually build: control-loop deadlines, lookup tables burned into flash, the FFT for vibration monitoring, circular buffers, and why you cannot simply "buy a faster computer" when the computer is bolted to the robot.

Read it last

The capstone assumes the whole course. Work through weeks 1–14 first, then read it to see why the whole thing mattered for your degree. It is linked at the foot of week 14, or here: Why Algorithm Analysis Belongs in Mechatronics →

08Sources and further reading

This course is deliberately narrower and slower than the textbook it draws on: fewer topics, more measuring, and every example rewritten for someone whose first line of Python was written in week 2.