Algorithms

Lecture for Applied Math. master students and for PhD students in Informatics

Spring 2021

Lecturer: Zoltán Király

Tuesday 10:15-11:45, TEAMS


Only for my students


Announcements

Online examination


Lecture 1 (FEB 9)

Algorithm, input, output. Number of steps (running time), big O notation. Linear, quasi-linear and quadratic algorithms..
Sorting and selecting problems.
4 algorithms for selecting the maximum. For correctly selecting the maximum at least n-1 comparisons are needed.
Selecting the minimum and the maximum all at once.

Further reading: [CLRS] Chapters 1, 2 and 3.

The whiteboard.

Video recorded during the lecture. Accessible until FEB 15.


Lecture 2 (FEB 16)

Finding the median. Dictionary problem. Binary search in a sorted array.
Simple algorithms for sorting: maximum-, bubble- and insertion-sort. Merge-sort.
Basics of data structures. Totally balanced binary trees. The definition of binary heaps. Storing a heap.

The whiteboard.

Video recorded during the lecture. Accessible until FEB 22.


Lecture 3 (FEB 23)

Storing a heap. Implementation of the operations in a heap: INSERT into the heap. DELETEMIN.
Heapsort. Building a heap. Selecting the ordered list of the k smallest elements.

Counting sort and radix sort.

The whiteboard.

Video recorded during the lecture. Accessible until MAR 1.


Lecture 4 (MAR 2)

Counting with big numbers: addition, subtraction, multiplication, integer division. Raising to a power.
Calculating modulo m. Euclidean algorithm, extended form. Division mod m, Chinese remainder theorem.

Running time of some algorithms.

Arrays, queues, stacks, linked lists (practice).

The whiteboard.

Video recorded during the lecture. Accessible until MAR 8.


Lecture 5 (MAR 9)

The classes P and NP. NP-completeness. Examples.
Dynamic programming: Fibonacci numbers and Knapsack (other examples in the practice).

Linked lists -- basics. Variants: in the practice.
How to store a graph?
Breadth-first search (BFS), idea, the core part of the algorithm.

The whiteboard.

Video recorded during the lecture. Accessible until MAR 15.


Lecture 6 (MAR 16)

Breadth-first search (BFS): deciding connectivity. Implementation, running time. Determining the components. finding a spanning tree, finding shortest paths, (deciding bipartiteness: in Practice).

Deciding connectedness needs cn^2 or m steps.
BFS on directed graphs, strongly connected components.

Min-cost spanning tree. Prim's algorithm. Implementation, running time.

The whiteboard.

Video recorded during the lecture. Accessible until MAR 22.


Lecture 7 (MAR 23)

Implementation with heaps. DECREASE-KEY in heaps. d-ary heaps.

Dijkstra's algorithm for shortest paths. Implementations, running time. Two applications: safest path, widest path.

The whiteboard.

Video recorded during the lecture. Accessible until MAR 29.


Lecture 8 (MAR 30)

Acyclic digraph (DAG), topological order. PERT. Shortest paths in DAGs.
Conservative weighting of directed graphs. The Bellmann--Ford algorithm. Potential, detecting negative cycles.

All-pairs shortest paths (Floyd-Warshall, Johnson).

The whiteboard.


Lecture 9 (APR 13)

Depth first search (DFS) and its applications.

Binary search trees, SEARCH and INSERT.

The whiteboard.

Video recorded during the lecture. Accessible until APR 19.


Lecture 10 (APR 20)

DELETE in binary search trees.

AVL trees.
Inner procedure: ROTATION.
INSERT into an AVL tree.

Basics of computational theory, Turing-machines, decidability and undecidability.

The whiteboard.

Video recorded during the lecture. Accessible until APR 26.


Lecture 11 (APR 27)

P and NP. Polynomial reduction, theorem of Cook, NP-completeness. Examples. co-NP, N\cap co-NP, the problem of integer factorization.

The basics of hashing, good hash functions, collisions.
Chaining.
Hash tables, open addressing, linear hashing. Universal and Cuckoo hashing.

The whiteboard.

Video recorded during the lecture. Accessible until MAY 3.


Lecture 12 (MAY 4)

Approximation algorithms.
Definitions. Traveling Salesman Problem (TSP), Steiner tree.
FPTAS for Knapsack.

The whiteboard.

Video recorded during the lecture. Accessible until MAY 10.


Lecture 13 (MAY 11)

FPT: Fixed Parameter Tractable problems.
Kernel, Vertex-Cover and Exact-Path.

The whiteboard.

Video recorded during the lecture.