Algorithms (2016/2017)

Course code
Romeo Rizzi
Teaching is organised as follows:
Unit Credits Academic sector Period Academic staff

Learning outcomes

The goal of this module is to introduce students to the main aspects of the computational complexity theory, and, in particular, to the NP-completeness theory and to the computational analysis of problems with respect to their approximability. Within the overall objectives of the CdS, this course allows students to widen and specialise their expertise in the analysis of algorithms and computational systems. It provides some advanced analysis tools to cope with non-trivial tasks. The students will acquire skills and knowledge to understand and cope with the computational difficulty in solving some common task. Students will be able to independently analyze a new problem, understand its structure and what makes it difficult and propose possible alternative approach to its solution (approximation, parametrisation) in the absence of provably efficient solutions.
Algorithms form the backbone and are at the very heart of computer science, but they also candidate as the most ancient precursors of informatics and are transversal and pervasive over all disciplines. Their design requires the study and comprehension of the structure of the problem at hand, and most of the time it means and results into the crowning of this effort. The study of algorithms requires and offers methodologies and techniques of problem solving, and logical and mathematical competences. The course aims at stimulating the students and guide them in their path to acquire the competencies and basic methodologies required when facing the analysis of problems and in the design of algorithms for their solution. A first target is to make the students fully aware that in order to obtain solutions (algorithms) you must first go through a study and comprehension of the problem. Particular emphasis is given to the methodological aspects: the study of special cases, the role of conjecturing, proof techniques, building a dialog with the problem, and detection of its structure. A second target is to build up a good relationship and active knowledge of the inductive approach, and accustom students with the use of recursion in practice. The students are challenged to slash induction as a queen problem solving tool. Among the dialects of induction introduced, we insist on memoization and dynamic programming. The student is required to acquire dynamic programming as a technique of problem solving and algorithm design. Particular emphasis is given to the efficiency of algorithms. Complexity Theory (of the twin didactic unit) plays a profound methodological role in the analysis of problems. A main target of the course is to explicit, emphasize and illustrate this role. Last but not least, the path and process comprising the solution of a problem must be complete. Thanks to the several didactic problems made available in the automatic evaluation system used during the laboratory sessions, the student experiments and learns how to manage all the following phases: study and comprehension of the problem, conception of an algorithmic solution, design of an efficient algorithm, planning the implementation, conducting the implementation, testing and debugging.


Computational models, computational resources, efficient algorithms and tractable problems. Relationships among computational problems. Polynomial reductions of one problem into another. The classes P, NP, co-NP. Notion of completeness. Proofs od NP-completeness: Cook's theorem; proofs of completeness using appropriate reductions. Search and Decision Problems. Self-Reducibility of NP-complete problems and existence of non-selfreducible problems. Recap of basic notions of computability: Turing Machines and Diagonalization. Hierarchy theorems for time complexity classes. Separability of classes and the existence of intermediate problem under the hypothesis the P is not equal NP. Space Complexity. Models and fundamental difference between the use of time resource and the space resource. The space complexity classes NL and L and their relationship with the time complexity class P. The centrality of the reachability problem for the study of space complexity. Completeness for space complexity classes: Log-space reductions; NL-completeness of reachability. Non-determinism and space complexity. Savitch theorem and Immelmann-Szelepcsenyi theorem. The classes PSPACE and NPSPACE. Examples of reductions to prove PSPACE-completeness. Introduction to the approximation algorithms for optimisation problems. Examples of approximation algorithms. Classification of problems with respect to their approximabuility. The classes APX, PTAS, FPTAS. Notion of inapproximability; the gap technique to prove inapproximability results; examples of approximation preserving reductions. Examples of simple randomised algorithms in solving hard problems. Recommended Prerequisites ------------------------- To attend the course in a productive way, a student should be confident with the following topics: 1. Basic data structures as list, stack, queue, tree, heap. 2. Graph representation and fundamental graph algorithms: 2.1 Graph visit: BFS, DFS. 2.2 Topological ordering. Connected component. 2.3 Minimal spanning tree. Kruskal and Prim algorithm. 2.4 Single-source shortest path: Dijkstra algorithm and Bellman-Ford one. 2.5 All-pairs shortest path: Floyd-Warshall algorithm and Johnson one. 2.6 Max flow: Ford-Fulkerson algorithm. A recommended book to revise the above topics is ``Introduction to Algorithms" di T. H. Cormen, C. E. Leiserson, R. L. Rivest e C. Stein (3 ed.).
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.

Assessment methods and criteria

When the student has collected, in its own mark wallet, both a positive mark for the Complexity module (at least 18) and a positive mark for the Algorithms module (at least 18), then he can ask for the recording of its final mark obtained as the rounded-up average of the above two marks, where 30+lode = 33. In order to get 30+lode as your final mark you need to get at least one lode and both marks should be at least 30. When you think your time has come to ask for registering this final mark, you send a mail to making precise:
1. mark for the Algorithms module: specify the session of the exam at which you got your best mark, this best mark, and the bonus points. (Specify the file in the mark wallet).
2. mark for the Complexity module: specify the last session of the exam where you delivered your elaborate for correction.
3. specify your generalities (student code VRxxxxxx) and the expected mark.

The whole workflow for obtaining your mark is described at:

At the same page 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. (For the Algorithms module, 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 mark.)
For the module-specific informations we redirect to the Didactic Dashboard sheets of the single module.

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
Ingo Wegener Complexity Theory Springer 2005
Christos H. Papadimitriou Computational complexity Addison Wesley 1994 0201530821
S. Arora, B. Barak Computational Complexity. A modern approach (Edizione 1) Cambridge University Press 2009 9780521424264
Garey, M. R. and Johnson, D. S. Computers intractability: a guide to the theory of NP-completeness Freeman 1979 0-7167-1045-5
T. Cormen, C. Leiserson, R. Rivest Introduction to algorithms (Edizione 1) MIT Press 1990 0262031418
Michael Sipser Introduction to the Theory of Computation PWS 1997 053494728X
Cristopher Moore, Stephan Mertens The Nature of Computation Oxford 2011
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein Introduction to Algorithms (Edizione 3) MIT Press 2009 978-0-262-53305-8