Algorithm Engineering (a.a. 2026‐27) - ferragina/AlgorithmEngineering GitHub Wiki
This is the material for the course "Algorithms Engineering" taught (since 2009, see the historical Algorithm Engineering's original page) in the master's programme in Computer Science and Networking, held at the Department of Computer Science of the University of Pisa
Teacher: Paolo Ferragina
CFU: 9 (first semester).
Course ID: 531AA.
Language: English.
Question time: Monday: 15-17, or by appointment (also via video conferencing through the virtual room of the course)
News: about this course will be distributed via a Telegram channel.
Official lecture schedule: The schedule and content of the lectures are available below and with the official registro.
In this course, we will study, design, and analyze advanced algorithms and data structures for the efficient solution of combinatorial problems involving all basic data types, such as integers, strings, (geometric) points, trees, and graphs. The design and analysis will involve several models of computation— such as RAM, 2-level memory, cache-oblivious, and streaming— in order to take into account the architectural features and the memory hierarchy of modern PCs and the availability of Big Data upon which those algorithms could work. We will add to such theoretical analysis several other engineering considerations arising from the implementation of the proposed algorithms and from experiments published in the literature.
Every lecture will follow a problem-driven approach that starts from a real software-design problem, abstracts it in a combinatorial way (suitable for an algorithmic investigation), and then introduces algorithms aimed at minimizing the use of some computational resources like time, space, communication, I/O, energy, etc. Some of these solutions will also be discussed at an experimental level, in order to introduce proper engineering and tuning tools for algorithmic development.
The course consists of 2 hours of lectures in the first three days of the week, from 9 AM to 11 AM.
- Monday: 9:00 - 11:00, Room Fib C
- Tuesday: 9:00 - 11:00, Room Fib E
- Wednesday: 9:00 - 11:00, Room Fib C1
The exam will consist of a written test including two parts: exercises and theory questions. The exam is passed if, in both parts, the student gets a sufficient score (out of 30), which is then averaged.
The first (exercises) and the second (theory questions) parts of the exam can be split into different exam dates, even in different exam sessions. The exam dates are indicated in the calendar on ESAMI. If the second part is not passed or the student abandons the exam, (s)he can keep the rank of the first exam as long as (s)he wishes. But if the student decides to improve her grade and takes that part of the exam again, (s)he loses the previous grade.
The schedule of the next exams follows, but the official dates/hours of the exams are in the website of the University of Pisa, where you have to register to participate in the exam.
- 09/11/2026, room D3 (Polo Fibonacci): MidTerm text, solution.
- **/12/2026: FinalTerm text, solution.
- **/01/2027, start at 9:00: text, solution.
I strongly suggest refreshing your knowledge about basic Algorithms and Data Structures by looking at the well-known book Introduction to Algorithms, Cormen-Leiserson-Rivest-Stein (third edition). Specifically, I suggest you look at chapters 2, 3, 4, 6, 7, 8, 10, 11 (no perfect hash), 12 (no randomly built), 15 (no optimal BST), 18, 22 (no strongly connected components). Also, you could look at the Video Lectures, by Erik Demaine and Charles Leiserson, specifically Lectures 1-7, 9-10, and 15-17.
The content of the course will be covered mostly by the book published by Cambridge University Press as Pearls of Algorithm Engineering (with its errata corrige).
If you wish to practice on the exercise part of the exam, here is a zipped file containing previous exercises.
The lectures below also include some additional material; we recommend it for students aiming for high rankings.
| Date | Topic | Notes and Refs |
|---|---|---|
| 15/09/26 | Refreshing some basic concepts on the analysis of algorithms: RAM model, time and space complexity, asymptotic analysis, polynomial versus exponential algorithms. Key issues about I/Os and hierarchical memory in managing massive datasets. The two-level memory model and I/O-costs. An example of I/O-analysis on the simple problem of summing items stored in an array. | Chap. 1 and slide. |
| 16/09/26 | Other examples of I/O-analysis: binary search versus B-tree search. The role of the Virtual Memory system: a probabilistic analysis. | Read B-tree note1 and note2. |
| Students are warmly invited to refresh their know-how about the divide-and-conquer technique for algorithm design, the Master Theorem for solving recurrence relations, and Binary Search Trees. | Lectures 2, 9, and 10 of Demaine's course | |
| 21/09/26 | Sorting versus Permuting, RAM versus two-level memory model. Permuting algorithm via sorting and scanning, and its I/O-bound. Comments on the I/O complexity of sorting and permuting. Binary MergeSort: I/O-analysis. | Sect. 5.1. |
| 22/09/26 | NO LECTURE | |
| 23/09/26 | The multi-way mergesort, with I/O analysis. Comments on the impact of data compression. Snow Plow, with complexity proof and an example. The case of D disks and the disk striping technique with I/O evaluation. | Sect. 5.1.2 (snow plow), and 5.4 (but no Greed Sort). |
| 28/09/26 | Lower bound for sorting: comparisons and I/Os. Quicksort: recap on best-case, worst-case, and average-case with analysis. 2-way, 3-way, and double-pivot partition for better in-memory quicksort. Bounded Quicksort with space analysis.
EXTRA is the lower bound on permuting (sect. 5.2.2). |
Sect. 5.2 and 5.2.1 (lower bound). Sect. 5.3, 5.3.1 (2- and 3-way QS), 5.3.3 (bounded QS) |
| 29/09/26 | How to choose a good pivot. Selection of kth-ranked item in O(n log n) time, O(n log k) time, and in linear average time (with proof). Multi-way Quicksort: definition, design, and I/O-complexity. | Sect. 5.3.2 (pivot selection), Sect. 5.3.4 (multi-way QS). |
| 30/09/26 | Selection of k-1 "good pivots" via Oversampling. Proof of the expected time complexity of Multi-way Quicksort. Random sampling: definition, a simple algorithm with its time complexity cost and cons. | Chap. 3 (random sampling) |
| 05/10/26 | NO LECTURE | |
| 06/10/26 | Random sampling: disk model, known length (algorithms and proofs). Random sampling on the streaming model: known length. Reservoir sampling on unknown-length streams: Algorithm and proofs. | Chap. 3 |
| 07/10/26 | NO LECTURE | |
| 12/10/26 | Randomized data structures: skip list with time/space analysis and comments on I/Os. What is a TREAP: construction and geometric interpretation. 3-sided range queries and their solution, with its output-sensitive time complexity. | see Demaine's lecture num. 12 on skip lists., Notes on Treaps. |
| 13/10/26 | More on TREAPS: 3-sided range query, insert, delete, split, merge, and proof of their time complexity. Proof of the average depth of a Random Binary Search Tree (i.e., TREAP with random priorities). | See notes previous lecture |
| 14/10/26 | On the intersection problem: brute-force solution, merge-based solution, binarySearch-based solution, mutual partitioning, doubling, two-level scan. Their time analysis. Lower bound and optimality. | Chap. 6. |
| OLD LECTURES TO BE UPDATED | ||
| /10/26 | Interpolation search, with its time and space analysis. | Sect. 9.3 (interpolation search). |
| //26 | String sorting: comments on the difficulty of the problem on disk, the lower bound. Multi-key Quicksort: algorithm and analysis. Ternary search tree. LSD-radix sort: asymptotic analysis in time and space, and proof of correctness. | Chap. 7 |
| //26 | String sorting: MSD-radix sort, uncompacted tries, and their implementation with arrays and hash tables. Prefix search: definition of the problem, reduction to lexicographic search of two types of pattern. Solution based on arrays, Front-coding, two-level indexing based on compacted tries. Analysis of space, I/Os, and time of all described solutions. EXTRA is the asymptotic analysis in time and space of MSD-radix sort (Sect. 7.2.1). |
Sect. 9.1 (array + FC), 9.4 (CT), 9.5 (PT). |
| //26 | Array-based string search. Two-level indexing based on Patricia Tries. Analysis of space, I/Os, and time of all described solutions. | |
| //26 | Substring search: definition, properties, reduction to prefix search. The Suffix Array. Binary searching the Suffix Array: p log n. Suffix Array construction via qsort and its asymptotic analysis. Array LCP and its construction in quadratic time. | All Chap. 10, but NO pages 156-158 for the use of LCP to get p + log n search (lemma 10.2). NO Skew and scan-based algorithms. NO sect 10.3.3. In sect 10.4 do only 10.4.4 (text mining). |
| //26 | Array LCP and its construction in linear time, with an example. Suffix trees: properties, construction from Suffix Arrays and LCP array, search operations. | |
| //26 | Text mining over suffix arrays and suffix trees, and other exercises. | |
| //26 | Hashing and hash tables: the dictionary problem, direct addressing, hashing with chaining, time and space complexity. Computational unfeasibility of simple uniform hashing. | Chap. 8 (i.e. 8.1 and 8.2) |
| //26 | Universal hashing (definition and properties). One example of Universal nash functions, with correctness proof. | Sect. 8.3, study all theorems with proof, except Theo 8.3 without proof (only the statement). |
| //26 | Other two examples of universal hash functions, without correctness proof. The "power of two choices" result. Cuckoo hashing: definition, operations, time/space complexity and an example. | Sect 8.5. |
| //26 | MIDTERM EXAM in Room **** (Polo Fibonacci) | . |
| //26 | Cuckoo hashing (with proofs). | |
| 12/10/25 | Minimal ordered perfect hashing: definition, properties, construction, space, and time complexity. Bloom Filter: properties, construction, query and insertion operations, error estimation (with proofs). | Sect. 8.6 and 8.7 (extra is 8.7.1, Lower bound on BF space; don't do compressed BF) |
| 17/11/25 | Discussion on the probability of error in BF. Application of Bloom Filters to DBs, search engines, and P2P. Spectral Bloom Filter and its probability of error. Prefix-free codes, the notion of entropy. Shannon's Theorem and optimal codes. | |
| 18/11/25 | Data Compression. Static, semistatic, and dynamic models for frequency estimation. Entropy. Huffman coding: definition, properties, relation to Entropy, and implementation. Canonical Huffman: definition, properties and implementation. EXTRA: Proof of Huffman's optimality and cost |
Chap. 12. |
| 19/11/25 | Arithmetic coding: algorithm, properties, the converter tool, correctness, and entropy bounds. Comparison against Huffman's coding. | |
| 24/11/25 | Dictionary-based compressors: properties and algorithmic structure. LZ77 and LZSS: algorithm, implementation, and the issue of the finite window. Integer coding: the problem and some considerations. The codes Unary, Gamma and Delta, Variable-byte, and their space/time performance, and consideration of optimal distributions. | Chap. 11 and 13 of the book. No (s,c)-dense code. No LZ78 and LZW. |
| 25/11/25 | Parameterised codes: Rice, PForDelta. Interpolative code. Exercises. | |
| 26/11/25 | Exercises on integer codes. | |
| 01/12/25 | Elias-Fano code: definition, properties, access and NextGEQ operations with their time/space complexity. | |
| 02/12/25 | Rank and Select: definition and succinct solution for Rank in read-only mode and o(m) space and O(1) time. How to implement Rank-Select with Elias-Fano and get compressed space. | Chap. 15: 15.1.1 (no Select implementation); 15.1.2 and 15.2.1 |
| 03/12/25 | Exercises | |
| 15/12/25, at 11:00, room D3 (Polo Fibonacci) | Final term exam |