General Info


Exercise classes Thursdays 8.00-9.45.

Class Room Study line Type Teaching Assistant
1 358/060a BEng Group Work/Danish Katrine Thoft, Tord Stordalen, Simon Tarnow, Alexander Bråten
2 358/042 BSc/BEng Group Work/English Gustav Valdemar Fjorder
3 324/020 BSc Presentation and Discussion/English Mads Okholm Bjørn
4 324/030 BSc Group Work/Danish Olav Nørgaard Olsen
5 324/040 BSc Group Work/Danish Christoffer Irvall Rasmussen
6 324/050 BSc Group Work/Danish Rikke Bertram Rasmussen
7 324/060 BSc Group Work/Danish Emil Toftegaard Gæde

The common area in 324 (F003, F004, F005, F008) is also reserved for the course.

Lectures Thursdays 10.00-12.00 in 303/42 (live), 303/41 (streamed), and 303/43 (streamed). The common area in 303A is also reserved for exercise sessions.

Materials "Introduction to Algorithms", 3rd edition (CLRS), Cormen, Leierson, Rivest, and Stein + notes. We encourage seeking out supplementary books and other sources for algorithms. Se suggestions here.

CodeJudge We use CodeJudge for testing code and correcting mandatory implementation exercises. See the first weekplan for instructions to access CodeJudge.

Gradescope We use Gradescope for correcting mandatory written exercises. See the first weekplan for instructions to access Gradescope.


The weekplan is preliminary and may be updated during the course.

Week Topics Slides Weekplan Material Algorithm Demos Programming Demos
Warmup: Preparation, Programming Prerequisites, and Puzzles. Warmup Survival Guide · Programming Prerequisites Factorial function
Basic Concepts I: Introduction, Algorithms, Data Structures, Peaks. 1x1 · 4x1 Introduction CLRS chap. 1 Recursive Peak Algorithm Peaks
Basic Concepts II: Searching, Sorting. 1x1 · 4x1 Searching and Sorting CLRS chap. 2 Binary Search · Insertion Sort · Merge · Mergesort Binary Search
Basic Concepts III: Complexity, Asymptotic Notation, Empirical Analysis. 1x1 · 4x1 Analysis of Algorithms CLRS chap. 3
Data Structures I: Stack, Queues, Linked Lists, Trees. 1x1 · 4x1 Introduction to Data Structures CLRS intro to part III + chap. 10 Stack with Array · Queue with Array · Dynamic Array 1 · Dynamic Array 2 Linked List
Graph Algorithms I: Undirected Graphs, Representation, Searching, Modelling. 1x1 · 4x1 Introduction to Graphs CLRS intro to part VI + chap. 22.1-22.4 + appendix B.4-B.5. DFS · BFS DFS
Graph Algorithms II: Directed Graph, Topological Sorting, Implicit Graphs. 1x1 · 4x1 Directed Graphs CLRS intro to part VI + chap. 22.1-22.4 + appendix B.4-B.5. Topological Sort Topological Sort
Data Structures II: Priority Queues, Heaps. 1x1 · 4x1 Priority Queues and Heaps CLRS chap. 6 + appendix B.5 Bubble up and down Heap
Data Structures III: Union-Find, Dynamic Connected Components. 1x1 · 4x1 Union-Find CLRS chap. 21 except 21.4 + Algorithms, 4ed. chap. 1.5 Quick Union · Weighted Quick Union
Graph Algorithms III: Minimum Spanning Trees, Prims' Algorithm, Kruskal's Algorithm. 1x1 · 4x1 Minimum Spanning Trees CLRS chap. 23. Prims' Algorithm · Kruskal's Algorithm
Graph Algorithms IV: Dijkstra's Algorithm, Shortest Paths in Weighted Graphs, Shortest Paths in DAGs. 1x1 · 4x1 Shortests Paths CLRS chap. 24 except 24.1 and 24.4. Dijkstras' Algorithm
Data Structures IV: Dictionaries, Hashing. 1x1 · 4x1 Hashing CLRS chap. 11 except 11.5. Chained Hashing · Linear Probing
Data Structures V: Algorithms on Trees, Predecessor Problem, Binary Search Trees. 1x1 · 4x1 Binary Search Trees CLRS chap. 12 except 12.4. Binary Search Trees
Course Wrap-Up: Questions, Selected Exercises from an Old Exam, Advanced Courses in Algorithms.

Mandatory Exercises

The course has mandatory exercises that must be passed inorder to attend the final exam. The mandatory exercises consist of written and implementation exercises:

Written exercises These are algorithmic challenges that must be answered in writing. These must be handed through Gradescope for correction by the TA's. Each written exercise is scored depending on the quality of your solution and your writing. It is a requirement for participation in the exam that you score at least 33 points in total in these exercises.

Implementation exercises These are programming challenges that must be implemented and handed in through CodeJudge for automatic evaluation and scoring. It is a requirement for participation in the exam that you score at least 33 points in total in these exercises.

Collaboration policy All mandatory exercises are subject to the following collaboration policy. The exercises should be done in groups of 2 or 1 (i.e., in pairs or individually). It is not allowed to collaborate with other groups 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 to other groups. It is not allowed to use solution from previous years, solutions from similar courses, or solutions found on the internet or elsewhere.

Old Exams

BSc BEng
02105-2017 02326-2017
02105-2018 02326-2018
02105-2019 02326-2019

Frequently Asked Questions

What programming and mathematics requirements do I need for the course? In general, you need an introductory course in programming and mathematics. Specifically, for programming you need only basic constructions such as conditional execution, loop, function calls, etc. See the programming prequisites under week 0 to test your programming skills. You can freely choose among standard imperative programming languages for the implementation exercises. For mathematics, the course uses and introduces basic topics from discrete mathematics and hence it is an advantage to have a course in it, but not a requirement.

What is the language of the course? The official language of the course is English. Hence the spoken language in lectures and the exam is in English. There are Danish exercise classes and your are free to hand in mandatory exercise and the exam in Danish.

What is the programming language used in the course? You can use most standard contemporary imperative programming languages (including Python, Java, C, and C++). The language must be supported by CodeJudge.

I need to quickly refresh my programming skills. What do you recommend? We suggest the book "Introduction to Programming in Java", Sedgewick and Wayne. The book is compact, concise, and focused on the core technical aspects of programming. The books covers essentially all relevant material for the course in chapter 1, which is freely available at the homepage for the book.

Which supplementary books/materials do you recommend? We suggest the following:

Do you provide solutions to exercises? Yes. We offer a personalized service for feedback on written exercises. You can submit any exercise on any weekplan at any point in time to any teacher. We will read it as soon as possible and provide detailed oral feedback.

What does "give an algorithm" mean? It means, that you describe your solution in a short, precise, and unambigious manner, argue correctness of your solution, and analyze the complexity of your solution. Unless specified otherwise, the description should be in natural language and not pseudocode.

Do you provide video recordings of lectures? No. We believe that efficient learning is achieved by more actively engaging with the material and exercises. Ideally, you should spend your time reading the material, working on exercises in groups, and discussing your solutions with your peers or teachers. If you want to watch videos of the material there are multiple sources available online for free covering almost all of the material in the course.

I get error X when I submit my program to CodeJudge. What should I do?/How do I find the bug?/Help! CodeJudge is for a final check of your code (does it produce the correct output for a given input (efficiently)?). To debug your code, construct small test examples and run them on your own computer.

How should I use to fill in the templates for the written mandatory assignments to comply with the requirements? We need to process your submission in the Gradescope system to efficiently grade your hand-ins and therefore it's essential that your closely follows requirement as stated in the exercise. If you do not follow the requirements you may risk having your hand-in being rejected. To produce your solution we highly recommend simply printing the template, filling it in by hand, and scanning it. Use one of the many excellent scanners available at campus or a good quality scanner app for your smartphone. Make sure that the quality of the scan is excellent. Ask your teachers for help if you are unsure about where to find a scanner or what a good quality smartphone scanner app is. Alternatively, there are numerous freely available tools for directly writing in the pdf you can use but it highly depends on your platform of choice. Ask your teachers for help if you are unsure about which tool to use.

I didn't make the deadline for a mandatory exercise. Can I hand in later? No. In special cases (e.g. illness) we can give an exemption. Talk to the course responsible during class or office hours.

Why didn't you reply to the email about X I sent you? We prioritize direct face-to-face communication. This way we can quickly understand your issue and help you much faster. Talk to us during class or office hours.

Do you provide an online forum for asking questions? No. We believe that personal interaction is a much better to properly guide you. We offer personal guidance during all exercise sessions and office hours (see above).

When and where is the exam? Please see the DTU exam schedule.

I've successfully passed the mandatory assignments at an earlier point in time but did no pass the corresponding exam. Will I have to do mandatory exercises again to attend another exam? Yes. A new set of mandatory exercises must be succesfully passed in the period immediately before an exam. This is highly relevant preparation for the exam and if you are unable to solve the mandatory exerices you are likely unable to pass the exam.

How does the re-exam work? The precise format is subject to change depending on the number of students and the current rules. Typically, the exam and mandatory assignments are very similar to those in the regular semester.

How do I sign up for the re-exam? Please see the DTU pages for how to sign up for a course or exam or ask relevant admin staff.