Professional Documents
Culture Documents
Scoring. Each problem is worth a maximum of 10 points, for a maximum total score of 50.
Problem 1. In Fig. 1 there is a weighted graph, circles represent vertices, links represent
edges, and numbers represent edge weights.
3
S C F
2 4
3 2 2
4 2 3
A D G T
3 1
1 1 1 1
2
B E H I
3 3 2
1. Find a shortest path from vertex S to vertex T , i.e., a path of minimum weight between
S and T .
2. Find a minimum subgraph (set of edges) that connects all vertices in the graph and
has the smallest total weight (sum of edge weights).
Problem 2.
1. Let E be a binary relation symbol representing adjacency in graphs. (That is, E(x, y)
means in a graph that “the vertices x and y are adjacent”.) Write a formula ϕ(x, y) in
the first-order logic over the language L = hEi with equality expressing that
Note that except logical symbols you may use only E and =. (The phrases “x and y
are adjacent” and “x and y are neighbors” have the same meaning.)
1
2. Find a model and a non-model of a theory
T = {(∀x)¬E(x, x), (∀x)(∀y)(E(x, y) → E(y, x)), (∀x)(∃y)ϕ(x, y)}
over the language L. By a non-model of T we mean a structure of the same language
that is not a model of T .
3. Is the formula (∃x)(∀y)ϕ(x, y) provable or refutable from T (in a sound and complete
proof system using the axioms of T )? Give an explanation for your answer.
Problem 3. Consider finite strings over the alphabet Σ = {a, b, c, d}. The power operation
represents string repetition, for example a3 b4 c denotes the string aaabbbbc. Define a context-
free grammar G generating the language L(G) = {w|(∃i, j, k)w = ai b(i+j+k) cj dk }, the set of
words where the number of b’s is the same as the number of all other letters together and
the letters are ordered alphabetically. For example, the words ab, aaabbbbd, abbbcd belong to
the language, words abba, aabbbbbc, abc do not belong to the language. Justify your answers.
Problem 4. Consider the following C++ program, and one of the C# or Java programs:
C++:
C#:
1 using System ;
2
3 class Program {
4 static void m <T >( T t ) { Console . WriteLine ( $ "m <T >( T ={ typeof ( T ) }) " ) ; }
5 static void m ( int i ) { Console . WriteLine ( " m ( int ) " ) ; }
6 static void f <T >( T t ) { m ( t ) ; }
7
8 static void Main ( string [] args ) {
9 f ( " Hello " ) ;
10 f (123) ;
11 f (4000000000) ;
12 }
13 }
2
Java:
For the chosen pair of the C++ and C# programs, or the C++ and Java programs, answer
the following:
1. What output will be printed by the C++ program, and what output by the second
language in the pair?
2. Explain why the C++ program behavior is different (in terms of methods called) from
that of the C# or Java one. Why do different methods get called?
3. In C++, C#, or Java, write a generic function that takes 3 arguments of any suitable
type T and returns their maximum value.
Time T1 T2 T3
(running top to bottom)
1 R1 (A)
2 W2 (B)
3 R3 (C)
4 R3 (B)
5 W1 (C)
6 W3 (B)
7 COMMIT3
8 ABORT2
9 COMMIT1
3
1. Find all conflicting pairs of operations in the schedule S.
If the schedule S lacks a particular property, correct it so that it satisfies the property without
changing the order of the read and write operations.
If the schedule cannot be fixed, describe why not.