Algorithms - ALGORITMI (2019/2020)

Course code
Name of lecturer
Romeo Rizzi
Number of ECTS credits allocated
Academic sector
Language of instruction
II semestre dal Mar 2, 2020 al Jun 12, 2020.

To show the organization of the course that includes this module, follow this link * Course organization

Lesson timetable

Go to lesson schedule

Learning outcomes

The course aims to build logical-mathematical skills, techniques, experience and methodologies useful in the analysis of algorithmic problems, from detecting their structure and analyzing their computational complexity to designing efficient algorithms, and then planning and conducting their implementation.

In the laboratory, the student will apply the main algorithmic techniques: recursion, divide and conquer, dynamic programming, some data structures, invariants and monovariants. Also at the exam she will address a complete path from the analysis of the problem, to the design of a resolver algorithm, to its coding and testing. What gets evaluated is the efficiency of the codes produced, as such, the student better know how to estimate the asymptotic costs of the designed algorithms, to identify the worst case scenario but also spot opportunities for an amortized analysis of the costs or to make use of appropriate data structures.

With this experience the student will acquire sensitivity about which problems can be solved efficiently and with which techniques, acquiring also dialectical tools to place the complexity of an algorithmic problem and identify promising approaches for the same, looking at the problem to grasp its structure. She will learn to produce, discuss, evaluate, and validate conjectures, and also independently tackle the complete path from the analysis of the problem, to the design of a resolver algorithm, to the coding and experimentation of the same, even in research contexts either in the private sector or at research institutions.


1. The workflow of problem solving: analysis and comprehension of the problem, conception of an algorithmic solution, design of an efficient algorithm, planning the implementation, conducting the implementation, testing and debugging.

2. Methodology in analyzing a problem:
The study of special cases. Particularization and generalization.
Building a dialog with the problem. Conjectures. Simplicity assumptions.
Solving a problem by reducing it to another. Reductions among problems to organize them into classes. Reducing problems to isolate the most fundamental questions. The role of complexity theory in classifying problems into classes. The role of complexity theory in analyzing problems. Counterexamples and NP-hardness proofs. Good conjectures and good characterizations. The belief can make conjectures true. Decomposing problems and inductive thinking.

3. Algorithm design general techniques.
Recursion. Divide et impera. Recursion with memoization. Dynamic programming (DP). Greedy.
DP on sequences. DP on DAGs. More in depth: good characterization of DAGs and scheduling, composing partial orders into new ones.
DP on trees. More in depth: adoption of the children one by one; advantages of an edge-centric vision over the node-centric one.
The asymptotic eye on worst case performance guides the design of algorithms:
the binary search example; negligible improvements; amortized analysis.
Some data structures: binary heaps; prefix-sums; Fenwick trees; range trees.

4. Algorithms on graphs and digraphs.
Bipartite graphs: recognition algorithms and good characterizations.
Eulerian graphs: recognition algorithms and good characterizations.
Shortest paths. Minimum spanning trees.
Maximum flows and minimum cuts.
Bipartite matchings and node covers.
The kernel of a DAG. Progressively finite games. Sums of games.

5. General hints on implementing, coding, testing and debugging.
Plan your implementation. Anticipate the important decisions, and realize where the obscure points are. Try to go round the most painful issues you foresee. Code step by step. Verify step by step. Use the assert. Testing and debugging techniques. Self-certifying algorithms.

Reference books
Author Title Publisher Year ISBN Note
Sanjoy Dasgupta, Christos Papadimitriou, Umesh Vazirani Algorithms (Edizione 1) McGraw-Hill Higher Education 2007 978-0-07-352340-8
T. Cormen, C. Leiserson, R. Rivest, C. Stein Introduzione agli Algoritmi e Strutture Dati (Edizione 2) McGraw-Hill 2005 88-386-6251-7
Steven S Skiena, Miguel A. Revilla Programming Challenges: The Programming Contest Training Manual (Edizione 2013) Springer New York, 2013 2003 147578970X

Assessment methods and criteria

Because of the CoVid19 emergency the organization and procedures of the exam have departed from what written more below in the official version. Since things are in continuous evolution, and we want to make sure no student gets lost, we redirect the student directly to the reference service site that we can maintain constantly updated:

We warmly advise every student to subscribe to the Telegram group for the 2020 edition of the course. This and other useful resources are conveniently accessed from the URL here above.


Students must face a 5 hours test held in computer room. Here, they are assigned some problems. The students must analyze and comprehend the problem and its structure, think of possible algorithmic solutions, design an algorithm and implement it in c/c++ or Pascal. The most efficient their algorithm is, the more points they will get.
During the exam, the students can submit their source codes to a site organized precisely as the one they have experimented during the exercise sessions in lab and/or at home. In this way they can get an immediate and contextual feedback that can guide them in conducting and managing their exam at their best.
Their solutions are evaluated based on the subtasks of the problem that they can solve correctly within the allotted computation time and memory as fixed by each single problem or subtask of it.
In this way, the efficiency of the solutions and algorithms they have designed and coded determines the final scores.
It is guaranteed that, at every exam session, at least one problem will be chosen among the problems that have been proposed and made available at the site for the home/laboratory exercises.
Often, other problems are taken from the COCI competitions or among problems of the olympiads in informatics or in problem solving.
Even after having achieved a positive vote, the student can participate to later exam sessions and see whether he can improve its current mark without any risk of reducing or tampering it anyhow: our policy is to keep the best mark ever.
To the mark from the exam are summed the points the students may have possibly collected in projects. As possible projects, this year we proposed the students to help us in designing problems and/or help us in the realization of a new system for the compilation of problem packages of new conception.
As such, each student has its own mark wallet. When the students decides he wants his (positive) mark registered, then the final mark is obtained as the average with the mark for the Computational Complexity twin module (which must also be positive in order to proceed) and this average is the mark for the whole course.

The site for the home/laboratory exercises:

and the problems you find there, are your first resource for preparing to your exam. The system you will encounter at the exam is a clone of it.

For more information on the modalities and possibilities at the exam, and for further preparation material, explore the site of the course (and help us improving it):

Here you can find the wallet of your marks for both the "Algorithms" and the "Computationl Complexity" modules comprising the course (if any), plus your extra scores for Algorithms in case you have collected any of them with projects.
You will also find here the problems given at previous exam sessions,
and more detailed instructions on the procedures for the exam and for the composition and registration of your final mark.