02110 Algorithms and Data Structures II

General Info | Mandatory Exercises | Weekplan | Programming Competition | Exam sets | FAQ | Fall 15 | Fall 16 | Fall 17 | Fall 18 | Fall 19 | Fall 20

General Info

Teacher Professor Inge Li Gørtz, office 011, building 322, Email: inge@dtu.dk.Office hours: Friday 12.00-12.45 on Zoom, Meeting ID: 681 9419 7720.

When Thursday 8-12. The course runs in the DTU fall semester.

Structure The class is structured as follows:

Where The exercise class from 8-10 is in building 116, room 012, 015, 016, 018, 019.
Lectures will be in building 116, aud. 81.

Textbook "Algorithm Design" by Kleinberg and Tardos. (KT)

Prerequisites The course builds on 02105 Algorithms and Data Structures I. You are expected to know the curriculum for 02105, which includes

CodeJudge Exercises marked with [CJ] are implementation exercises and can be tested in CodeJudge (CodeJudge). For each of these exercises, a detailed specification of the input/output can be found on CodeJudge.

Programming Competition

We will have a programming competition with a prize for the best three teams. More info follows later.


The weekplan is preliminary. It will be updated during the course.

Week Topics Slides Weekplan Material Demos
Warmup Warmup
Divide-and-Conquer: Recurrence relations, Mergesort (recap), integer multiplication 1x1 · 4x1 DC
  • KT 4.1, 4.2, 4.5
  • (KT 5.1, 5.2, 5.5 in the American edition)
Dynamic programming I: Introduction, weighted interval scheduling, Knapsack 1x1 · 4x1· full DP1
  • KT 6.1, 6.2, 6.4
Dynamic programming II: Sequence alignment and shortest paths 1x1 · 4x1 DP2
  • KT 6.6, 6.8.
Sequence Alignment
Network Flow I: Max-cut min-flow theorem, augmenting paths, Ford-Fulkerson 1x1 · 4x1 · full Flow1
  • KT 7.1, 7.2
Ford Fulkerson and min cut
Network Flow II: scaling, Edmonds-Karp, applications, maximum bipartite matching, disjoint paths
1x1 · 4x1 · full Flow2
  • KT 7.3, 7.5, 7.6
  • KT 7.7, 7.8, 7.9, 7.10, 7.11
Data Structures I: Red-Black trees and 2-3-4 trees 1x1 · 4x1 Balanced Search Trees
  • Algorithms in Java by Sedgewick, page 572--585 (on DTU Learn)
  • Supplementary reading: CLRS chapter 13 (on DTU Learn)
Data Structures II: Amortized Analysis + splay trees. 1x1 · 4x1 · full Amortised Analysis
  • Section 15 + 16.5-16.6 in notes by Jeff Erickson (can also be found on DTU Learn)
  • Chapter 17 in Algorithms from Cormen, Leiserson, Rivest, Stein (can be found on DTU Learn).
Splay 0211 Trees
Splay Trees Deletions
Data Structures III: Partial Sums and Dynamic Arrays 1x1 · 4x1 Partial Sums and Dynamic Arrays
String matching 1x1 · 4x1 Strings
  • CLRS 32.0, 32.3, 32.4 (on DTU Learn)
Automata matching and construction
KMP matching and construction
Randomized Algorithms I: Contention resolution and minimum cut.
1x1 · 4x1 Contention resolution and minimum cut
  • KT 12, 12.1, 12.1, 12.2, 12.12 (In the American edition it is chapter 13)
Randomized algorithms II: selection, quicksort
1x1 · 4x1 Randomized Algorithms II
  • KT 12.3, 12.5 (In the American edition it is chapter 13)
Introduction to NP-completenes 1x1 · 4x1 NP
  • KT 8.0, 8.1
  • KT 8.3 (except the proof of 8.10)
  • KT 8.4 (only introduction and the subsection A General Strategy for Proving New Problems NP-Complete)
Questions, repetition, prize for programming competition

Mandatory assignments

The course has mandatory exercises that counts in the final grade. The mandatory exercises consist of written and implementation exercises:

Written assignments These are algorithmic challenges that must be answered in writing. These must be handed through DTU Learn. Each written exercise is scored depending on the quality of your solution and your writing.

Implementation assignments These are programming challenges that must be implemented and handed in through CodeJudge for automatic evaluation and scoring.

The deadline for handing in the assignments must be respected.

Collaboration policy THe mandatory exercises are subject to the following collaboration policy. The mandatory exercises are individual. It is not allowed to collaborate on the exercises, except for discussing the text of the exercise with teachers and fellow students enrolled on the course in the same semester. Under no circumstances is it allowed to exchange, hand-over or in any other way communicate solutions or part of solutions to the exercises. It is not allowed to use solution from previous years, solutions from similar courses, or solutions found on the internet or elsewhere. It is not allowed to search for solutions or parts of solutions on the internet.

Old Exam Sets

Here is the exam set from some of the previous years: ExamE19 ( solution (very brief)), ExamE18, ExamE17 ( solution (very brief)), ExamE16, ExamE15, ExamE14 and a solution to E14.
And an example exam: ExampleExam.

Solutions to selected exercises

Here are solutions to a couple of exam like exercises, such that you can see how a well written solution could be: Example solutions.

Frequently Asked Questions

How should I write my mandatory exercises? Here is a few tips:

Can I write my assignments in Danish? Ja. Du er meget velkommen til at aflevere på dansk. Det samme gælder til eksamen.

What do I do if I want to do a MSc/BSc thesis or project in Algorithms? Great! Algorithms is an excellent topic to work on :-) and Algorithms for Massive Data Sets is designed to prepare you to write a strong thesis. Some basic tips and points.