AA · 14 weeks · Dr. Arif Solmaz

Algorithm Analysis

Trace a method, count its work and explain your choice. Each week has one lesson with diagrams, examples and three core tasks.

Python · Mechatronics engineering

Course resource

Algorithm Analysis notes — English & Turkish (Skiena CSE 373) · Word document · 468 KB

Weekly lessons

WeekTopicLesson
01What Is an Algorithm?Trace a method. Draw what changes. Count the work.Open →
02Your First Python: Values, Names, and Outputprint, variables, numbers, text — the four things you need before anything else.Open →
03Repeating Work: Loops and a Step Counterfor, range, and while — plus counting how many steps your program really takes.Open →
04Lists: Holding Many Things at OnceMaking lists, reading items, searching with in — and feeling work grow with size.Open →
05Functions and the StopwatchWrap work in a function, then time it honestly with perf_counter and repeats.Open →
06The Doubling ExperimentDouble n, look at the time: flat, twice as slow, or four times as slow?Open →
07Counting Steps Instead of SecondsSeconds depend on your laptop; step counts don't. Meet T(n) and the dominant term.Open →
08Big-O NotationOne short symbol for a growth story: O(1), O(log n), O(n), O(n log n), O(n²), O(2ⁿ).Open →
09One Problem, Four Algorithms: The Anagram StoryThe classic case study — four correct solutions, four completely different costs.Open →
10What Python Lists Really Costappend vs insert(0), pop() vs pop(0), + vs comprehension — measured, not guessed.Open →
11Dictionaries and Sets: Faster LookupsHashing intuition and the single biggest speed win a beginner can learn.Open →
12Searching: Linear vs BinaryGuess-the-number, the phone book trick, and why log n barely grows.Open →
13Sorting: Why Some Sorts Are SlowBubble and selection sort by hand, then Python's sorted() — n² vs n log n on a plot.Open →
14Putting It All TogetherA checklist for choosing, the classic 'accidentally quadratic' traps, and the final project.Open →
Course information, assessment & resources

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.

Office hours: Wednesday, 09:00–11:00 AM.

Who this is for

Mechatronics Engineering students who need algorithms that remain dependable under sensor, control-loop, memory, and embedded-computing constraints. No prior programming fluency is assumed; each method is explained with examples you can run.

03AThe three-hour class plan

TimeWhat students do
00:00–00:10Opening question, quick review, and today’s goals
00:10–01:00Explain → predict → run → discuss; checkpoint and questions
01:00–01:10Break
01:10–02:00Worked example → variation → peer explanation; checkpoint
02:00–02:10Break
02:10–02:50Engineering practice and an exam-style question
02:50–03:00Open questions, summary, and exit ticket

The official timetable determines the start and finish. Questions are welcome at any point, and both checkpoints reserve time for them. Weekly work stays with the student; there is no notebook upload or after-class homework grading.

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 can avoid repeated searches.

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. Optional Studio Extension — 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.

06Assessment

ComponentWeightWhat it is
Midterm50%Trace short code, count operations, identify growth, and justify each conclusion.
Final exam50%Apply the weekly reasoning moves to new inputs and engineering scenarios.

Weekly self-checks are private practice and are never collected. Exam questions use the same skills each week—follow the steps, count work, name the growth pattern, compare methods, explain results, and justify—but change the data or engineering context. Assessment consists only of the midterm exam (50%) and final exam (50%). Weekly notebooks, exercises, projects, demonstrations and presentations are ungraded practice; no weekly submission is required.

07The practice 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.
Practice emphasis

The faster program does not automatically win. A project that measures carefully, explains an unexpected result and admits what it could not test provides stronger evidence 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

  • Miller & Ranum, Problem Solving with Algorithms and Data Structures using Python — the Algorithm Analysis chapter is the backbone of weeks 7–11, including the anagram case study and the Python operation-cost tables. Free and interactive.
  • The Python documentation on time complexity of built-in operations — the reference table behind weeks 10 and 11.
  • Steven Skiena, The Algorithm Design Manual — the Chapter 2 exercises are woven through the weekly problem sets and solved at a beginner level, so students meet a respected professional reference without being thrown in the deep end.
  • For students who want the next step after this course: the companion Data Structures & Algorithms course, which assumes everything here.

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.

Optional advanced topics

About the supplied reading and exercises

The weekly introductions adapt Analysis of Algorithms — Extended Beginner Notes (Skiena CSE 373), dated 18 September 2026. Practice uses Analysis of Algorithms — Exercises with Answers (Skiena CSE 373), with its original exercise numbers. Wording and solutions have been clarified where assumptions or corrections are needed.

Lectures 1–9 support the existing weekly topics. Lectures 10–22 are condensed into optional extensions. The original 14-week sequence and assessment rules still apply.

Reference library · Textbook solutions