Sei sulla pagina 1di 1

Master’s Programme in Computer Science 2018

University of Helsinki
Preliminary Assignment for Applicants 1/1

Please read the material carefully and then solve the three tasks given at the end of this
document. Be clear and neat. Return a single PDF file.

Partially ordered set

The concept of a partially ordered set has numerous applications in computer science, for
example, in the analysis of sorting algorithms and in implementations of distributed systems.

A partially ordered set (poset) is a pair (P, ≺) where P is a set of elements and ≺ is a binary
relation on P that is irreflexive (i.e., x 6≺ x for all x ∈ P ) and transitive (i.e., x ≺ y, y ≺
z =⇒ x ≺ z for all x, y, z ∈ P ). When the partial order ≺ is clear from context, we identify
the poset with the ground set P .

The cover graph of a poset (P, ≺) is the directed graph (P, E), where P is the set of vertices
and E contains an edge (x, y) if and only if x ≺ y and there is no z such that x ≺ z ≺ y.

An element x of poset P is minimal if y ⊀ x for all y ∈ P .

Example. Let P = {1, 2, 3, 4} and let ≺ be the usual ordering of the integers in P , that is,
x ≺ y if and only if x < y. Then ≺ is a partial order on P , the cover graph has exactly three
edges, namely (1, 2), (2, 3), and (3, 4), and the only minimal element is 1.

Tasks
1. (max 1 point) Let P consist of all subsets of the set {1, 2, 3, 4}. How many edges does
the cover graph of the poset (P, ⊂) have? Here ⊂ is the subset relation: A ⊂ B if and
only if A is a proper subset of B.
2. (max 8 points) Describe a data structure for representing posets that supports the
following operations within the given worst-case time requirements:
Init(C): Constructs the data structure given a cover graph C = (P, E) as input, repre-
sented by an adjacency list. The worst-case time requirement should be O(|P |2 ).
DelMin(x): Removes the given minimal element x from the represented poset (P, ≺);
the resulting poset (P 0 , ≺0 ) is given by P 0 = P \ {x} and ≺0 =≺ \{(x, y) : x ≺ y}.
The worst-case time requirement should be O(|P |).
ListMin: Outputs a list that contains every minimal element of the poset exactly once
(and nothing else). The worst-case time requirement should be O(|P |).
Use pseudocode and argue why the operations meet the time requirements. You may
assume the given arguments are valid: you need not implement error handling.
3. (max 6 points) Implement the operations in the previous task using one of the following
programming languages (using only standard libraries): C, C++, Java, Python. Show
your code.
Let C be the cover graph of Task 1. Show the output of your code after the following
sequence of operations: Init(C), DelMin(∅), DelMin({3}), DelMin({1}), ListMin.

Potrebbero piacerti anche