Algorithms

Lecture for Applied Math. master students

Spring 2022

Lecturer: Zoltán Király

Friday 10:15-11:45, TEAMS, and later D.3.719.


Only for my students


Announcements


Lecture 1 (FEB 11)

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. Selecting the largest and the second largest elements.

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


Lecture 2 (FEB 18)

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.


Lecture 3 (FEB 25)

Totally balanced binary trees. The definition of binary heaps. 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.


Lecture 4 (MAR 4)

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

The classes P and NP. NP-completeness. Examples.


Lecture 5 (MAR 11)

Linked lists and queues.
Dynamic programming: Fibonacci numbers and Knapsack (other examples in the practice).

How to store a graph?
Breadth-first search (BFS), idea, the core part of the algorithm, deciding connectivity, implementation, running time.


Lecture 6 (MAR 18)

Breadth-first search (BFS): Deciding connectedness needs cn^2 or m steps.
Determining the components. finding a spanning tree, finding shortest paths, (deciding bipartiteness: in Practice).

BFS on directed graphs, strongly connected components.

Min-cost spanning tree. Prim's algorithm. Implementation, running time. Implementing using edge-lists and heaps: We need n DELETE-MIN, n INSERT and m DECREASE-KEY operations.


Lecture 7 (MAR 25)

Implementing DECREASE-KEY in heaps. d-ary heaps.

Dijkstra's algorithm for shortest paths. Implementations, running time. Two applications: safest path, widest path. Acyclic digraph (DAG), topological ordering, finding it in O(m).


Lecture 8 (APR 1)

Method PERT. Shortest paths in DAGs.
Conservative weighting of directed graphs. The algorithm of Bellmann and Ford. Potential, detecting negative cycles.

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


Lecture 9 (APR 8)

Depth first search (DFS) and its applications.

Binary search trees, SEARCH and INSERT.
DELETE in binary search trees.

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


Lecture 10 (APR 22)

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

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 families of hash functions. Cuckoo hashing.


Lecture 11 (APR 29)

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


Lecture 12 (MAY 13)

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