Skip to content

Algorithms

A course of the Operations Research and Mathematics series · all the courses

Teaching material conceived and developed by Fabio Furini, associate professor at DIAG, Sapienza University of Rome.

The course presents algorithms in four parts: basic algorithms (representation of numbers, pseudo-code, sorting, searching, numerical algorithms), the programming languages C++, Python and Java, the growth of functions and asymptotic notation, the analysis of algorithms and recursion (running time, correctness, recurrence relations, the Master Theorem).

Start Exercises Lab Quiz Downloads

Try it now

Merge sort during the last merge: the tree of the calls, the two sorted halves L and R and the array being filled. Press ▶ to replay it from the start, step by step.

More apps in the lab

The parts of the course

  • 1 · Basic algorithms


    The representation of numbers and pseudo-code, the language in which all the algorithms of the course are written; the first algorithms: sorting (insertion, exchange and selection sort), linear and binary search, numerical algorithms (change of base, primality test, sieve of Eratosthenes, greatest common divisor). Every algorithm with its pseudo-code and examples executed step by step.

    The chapters

  • 2 · Programming languages


    From pseudo-code to programs: three programming languages, C++ (compiled), Python (interpreted) and Java (compiled to bytecode and run by a virtual machine). For each: variables and data types, input and output, operators, conditional statements, loops, arrays and lists, functions, bitwise operators and a complete algorithm, with the comparison of the three languages.

    The chapters

  • 3 · Asymptotic notation and growth


    How the functions of a natural variable that count the steps of an algorithm are compared: the asymptotic notations Theta, big O, Omega, little o and omega, their properties and the limit criterion; then the families of increasing functions (logarithms, powers, exponentials, factorial), the hierarchy of infinities and the comparison of orders of growth written with the symbols. Limits and functions of a natural variable are taken from the course of Mathematical Analysis 1.

    The chapters

  • 4 · Analysis of algorithms


    The analysis of algorithms: the input size, the running time in the best, worst and average case, and correctness proved with loop invariants.

    The chapters

  • 5 · Recursion


    Recursion: classical recursive algorithms, recurrence relations, the Master Theorem, recursive algorithms (array sum, merge sort, binary search, maximum subarray) and the comparison between recursive and iterative versions.

    The chapters

Don't miss

  • Exercises with solutions


    Exercises for every chapter, each with its worked solution that opens with a click.

    The exercises

  • Self-assessment quiz


    A new mock exam at every start: 13 questions, 33 points, with the solution and the link to the notes. Downloads also has the full question bank.

    Test yourself

  • Interactive lab


    Apps running in the browser: move the parameters and watch the ideas of the course at work, one step at a time.

    The lab

  • Lecture notes in PDF


    Lecture notes, exercise books and slides in PDF, with the same numbering as the website.

    Downloads

  • Notebooks in Colab


    The code of the course running in the browser, with nothing to install.

    The notebooks

  • Full index


    All the chapters with their sections on one page, and how each chapter is organized.

    The index


The series

All the courses of the series are built the same way: lecture notes online and in PDF, exercises with solutions, an interactive lab and self-assessment quizzes.

  • Mathematical Analysis 1

    real numbers, functions, limits, derivatives and series, with interactive graphs

  • Linear Algebra

    vectors, matrices, determinants, linear systems and eigenvalues, with the computation lab

  • Algorithms · this course

    number representation, pseudo-code, sorting and searching, analysis and recursive algorithms

  • Linear Programming

    polyhedra, the simplex algorithm, duality and the dual simplex, with the interactive lab

  • Integer Linear Programming

    LP relaxation, valid inequalities, cutting planes, branch-and-bound and branch-and-cut

  • Convex Optimization

    convex sets and functions, convex optimization problems, with interactive graphs

  • Network Optimization

    graphs, spanning trees, shortest paths, network flows, the network simplex and project management

  • Combinatorial Optimization Problems

    knapsack, bin packing, coloring, TSP, scheduling and lot sizing: the problems, their formulations and ad hoc algorithms

  • Dynamic Programming

    principles and DP algorithms for knapsack, lot sizing, coin change and rod cutting

  • Heuristic Algorithms

    constructive heuristics, local search, metaheuristics and MIP heuristics for combinatorial optimization problems

  • Approximation Algorithms

    performance guarantees, approximation schemes and limits of approximation for combinatorial problems

  • LP Modelling

    linear programming models of managerial problems, solved with Python and Gurobi

  • NLP Modelling

    nonlinear programming models, from portfolios to machine learning, with Python and Gurobi

  • MIP Modelling

    integer linear programming models, from the formulation to the solution with solvers


Teaching material by Fabio Furini — DIAG, Sapienza University of Rome.

This website is also available in Italian.

The lecture slides, one PDF per chapter, are on the Downloads page.