TExcelTAD

Exercises

Thirteen problems covering the whole course: FPT algorithms, kernels, treewidth, parameterized lower bounds and fine-grained reductions. Each has a short Answer and a full Solution; several solutions include a program that checks the result by brute force. Work each one on paper first.

Tip: For an FPT claim, name the parameter, the branching vector or kernel size, and the polynomial factor. For a lower bound, name the hypothesis and check that the reduction keeps the parameter (or the exponent) under control.

# Exercise Practises
1 FPT, XP or neither? definitions
2 Two branching vectors branching numbers
3 Buss's rules by hand kernels
4 Crowns in a star and a path crown decompositions
5 Two LP solutions for a path Nemhauser-Trotter
6 Find the sunflower sunflower lemma
7 How many colorings? color coding
8 Treewidth of a small graph tree decompositions
9 Independent set on a cycle by DP treewidth DP
10 Parameterized or not? parameterized reductions
11 A fast 3-coloring algorithm? ETH
12 Sizes in split and list SETH, OV
13 A negative triangle by min-plus APSP

Exercise 1: FPT, XP or neither?

Classify each running time for a problem with parameter kk and input size nn: (a) O(kkn2)O(k^k n^2); (b) O(nk)O(n^{\sqrt{k}}); (c) O(22k+n3)O(2^{2^k} + n^3); (d) O(nlog⁡n)O(n^{\log n}) for every kk; (e) O(k⋅nk/100)O(k \cdot n^{k/100}).

Answer

(a) FPT; (b) XP, not FPT form; (c) FPT; (d) neither: not even polynomial for fixed kk; (e) XP.

Solution

FPT means f(k)⋅ncf(k) \cdot n^{c} with cc a constant. (a) has f(k)=kkf(k) = k^k, c=2c = 2. (c) is f(k)+n3f(k) + n^3, which is at most f(k)⋅n3f(k) \cdot n^3 for n≥2n \ge 2. XP means f(k)⋅ng(k)f(k) \cdot n^{g(k)}: (b) and (e) have the parameter in the exponent of nn; the factor 1100\frac{1}{100} in (e) does not help, the exponent still grows with kk. (d) does not depend on kk but is superpolynomial in nn for every fixed kk, so it is not XP either (Parameters, FPT and XP).

Exercise 2: Two branching vectors

A vertex cover algorithm branches on a vertex vv of degree at least 4 whenever one exists (vector (1,4)(1, 4)), and otherwise on a degree-3 vertex with a rule that gives the vector (2,3)(2, 3). What is the base of its running time?

Answer

max⁡(1.3803,1.3247)=1.3803\max(1.3803, 1.3247) = 1.3803: the running time is O∗(1.3803k)O^*(1.3803^k), assuming the remaining cases (max degree at most 2) are solved in polynomial time.

Solution

The tree size is governed by the worst branching vector that can occur (Branching Vectors and a Faster Vertex Cover). The roots of 1=x−1+x−41 = x^{-1} + x^{-4} and 1=x−2+x−31 = x^{-2} + x^{-3}:

python · try it yourself
def base(vec):
    lo, hi = 1.0, 3.0
    for _ in range(100):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if sum(mid ** -t for t in vec) > 1 else (lo, mid)
    return hi

for v in [(1, 4), (2, 3), (1, 3)]:
    print(v, round(base(v), 4))
(1, 4) 1.3803
(2, 3) 1.3247
(1, 3) 1.4656

The overall base is the larger one, 1.3803. (If degree-3 vertices had to use (1,3)(1, 3), the base would be 1.4656.)

Exercise 3: Buss's rules by hand

The graph is a star with centre cc and 10 leaves, plus a separate triangle xyzxyz. Apply Buss's rules with k=3k = 3. What remains, and what is the answer?

Answer

cc is forced (kk becomes 2); the leaves become isolated and are deleted; the triangle remains with k′=2k' = 2, it has 3 edges ≤4=k′2\le 4 = k'^2, and the answer is YES ({c,x,y}\{c, x, y\}).

Solution

cc has degree 10>310 > 3, so it is in every cover of size at most 3: delete it, k=2k = 2. The ten leaves are now isolated: delete them. The triangle's vertices have degree 2≤22 \le 2, so no more vertices are forced; the triangle has 3 edges and k′2=4k'^2 = 4, so the instance passes the edge test. The kernel is (K3,2)(K_3, 2), a YES instance since any two triangle vertices cover it (Kernels and Buss's Rule for Vertex Cover).

Exercise 4: Crowns in a star and a path

Give a crown decomposition (C,H,R)(C, H, R) of (a) the star K1,5K_{1,5} and (b) the path 1−2−3−4−51 - 2 - 3 - 4 - 5. What does the crown rule do in each case?

Answer

(a) CC = the five leaves, HH = the centre, R=∅R = \emptyset: the rule takes the centre and the graph disappears. (b) For example C={1}C = \{1\}, H={2}H = \{2\}, R={3,4,5}R = \{3, 4, 5\}: take 2, leaving the path 3−4−53 - 4 - 5; again C={5}C = \{5\}, H={4}H = \{4\} leaves the single vertex 3. Total cover {2,4}\{2, 4\}, optimal.

Solution

In (a) the leaves are independent, their neighbourhood is the centre, and any one leaf-centre edge is a matching saturating HH. In (b) the pendant vertex 1 with its neighbour 2 is the degree-1 rule as a crown: C={1}C = \{1\} independent, N(C)={2}=HN(C) = \{2\} = H, matched by the edge 12, and no edge from 1 to RR. Larger crowns work too: C={1,3}C = \{1, 3\}, H={2,4}H = \{2, 4\} is a crown (independent, N(C)={2,4}N(C) = \{2, 4\}, matching {12,34}\{12, 34\}, and 5 is adjacent only to 4), giving the same cover at once (Crown Decompositions).

Exercise 5: Two LP solutions for a path

For the path a−b−c−da - b - c - d, give two optimal half-integral solutions of the vertex cover LP, one integral and one with every value 12\frac{1}{2}. What kernel does each give?

Answer

x=(0,1,1,0)x = (0, 1, 1, 0) and x=(12,12,12,12)x = (\frac{1}{2}, \frac{1}{2}, \frac{1}{2}, \frac{1}{2}), both of value 2. The first gives an empty kernel with V1={b,c}V_1 = \{b, c\} in the cover; the second leaves the whole path.

Solution

The LP value is at least 2 because edges abab and cdcd are disjoint and each needs total value 1. Both solutions reach 2. Nemhauser-Trotter applies to any optimal half-integral solution (The Nemhauser-Trotter LP Kernel), so the kernel depends on which one the solver returns; the theory only guarantees ∣V1/2∣≤2k\lvert V_{1/2} \rvert \le 2k. Implementations prefer solutions with as few halves as possible: from any optimal solution one can compute in polynomial time one whose V1/2V_{1/2} is minimal.

Exercise 6: Find the sunflower

In the family {1,2,3},{1,4,5},{1,6,7},{2,4,6},{3,5,7},{1,2,8}\{1,2,3\}, \{1,4,5\}, \{1,6,7\}, \{2,4,6\}, \{3,5,7\}, \{1,2,8\}, find a sunflower with 3 petals. Is there one with 4 petals?

Answer

{1,2,3},{1,4,5},{1,6,7}\{1,2,3\}, \{1,4,5\}, \{1,6,7\} with core {1}\{1\} (and also {1,4,5},{1,6,7},{1,2,8}\{1,4,5\}, \{1,6,7\}, \{1,2,8\}). With 4 petals: no.

Solution

The three sets containing 1 with otherwise disjoint elements form a sunflower with core {1}\{1\}. A 4-petal sunflower with core {1}\{1\} would need a fourth set through 1 disjoint from {2,3},{4,5},{6,7}\{2,3\}, \{4,5\}, \{6,7\} outside 1; the only other set with 1 is {1,2,8}\{1,2,8\}, which meets {1,2,3}\{1,2,3\} in {1,2}\{1,2\}. With an empty core we would need 4 pairwise disjoint sets, but at most one of them can contain 1 and only two sets avoid 1. Checking all triples and quadruples confirms this:

python · try it yourself
from itertools import combinations

F = [{1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, {3, 5, 7}, {1, 2, 8}]
def is_sunflower(sets):
    core = set.intersection(*sets)
    return all(a & b == core for a, b in combinations(sets, 2)), core
for p in [3, 4]:
    found = [[sorted(A) for A in S] for S in combinations(F, p) if is_sunflower(list(S))[0]]
    print(p, "petals:", found if found else "none")
3 petals: [[[1, 2, 3], [1, 4, 5], [1, 6, 7]], [[1, 4, 5], [1, 6, 7], [1, 2, 8]]]
4 petals: none

Exercise 7: How many colorings?

Color coding for kk-PATH with k=10k = 10: how many random colorings are needed so that a fixed 10-path is colorful in at least one of them with probability at least 0.99?

Answer

About 12,700 colorings: r≥ln⁡(100)⋅101010!≈12,690r \ge \ln(100) \cdot \frac{10^{10}}{10!} \approx 12{,}690.

Solution

The probability of being colorful is p=10!1010≈3.63⋅10−4p = \frac{10!}{10^{10}} \approx 3.63 \cdot 10^{-4} (Color Coding and Long Paths). The failure probability after rr rounds is (1−p)r≤e−pr(1 - p)^r \le e^{-pr}, which is at most 0.010.01 when r≥ln⁡100pr \ge \frac{\ln 100}{p}.

python · try it yourself
import math
p = math.factorial(10) / 10 ** 10
r = math.ceil(math.log(100) / p)
print(f"p = {p:.3e}, rounds = {r}, exact failure (1-p)^r = {(1 - p) ** r:.5f}")
p = 3.629e-04, rounds = 12691, exact failure (1-p)^r = 0.00999

Exercise 8: Treewidth of a small graph

The graph has vertices 1,…,51, \ldots, 5 and edges 12,13,23,24,34,4512, 13, 23, 24, 34, 45 (two triangles 123123 and 234234 sharing the edge 2323, plus the pendant edge 4545). Give a tree decomposition of minimum width and prove it is minimum.

Answer

Bags {1,2,3}−{2,3,4}−{4,5}\{1,2,3\} - \{2,3,4\} - \{4,5\} in a path; width 2. The treewidth is 2.

Solution

All edges lie in a bag (12,13,2312, 13, 23 in the first; 24,3424, 34 in the second; 4545 in the third), and each vertex's bags are consecutive: 2 and 3 in the first two, 4 in the last two. The width is 3−1=23 - 1 = 2. It cannot be 1: the graph contains a triangle, and a clique must lie in one bag (Tree Decompositions and Treewidth).

Exercise 9: Independent set on a cycle by DP

Using the path decomposition {0,i,i+1}\{0, i, i+1\}, i=1,…,n−2i = 1, \ldots, n - 2, of the cycle CnC_n, run the independent set DP for C7C_7 with weights 3,1,4,1,5,9,23, 1, 4, 1, 5, 9, 2 on vertices 0,…,60, \ldots, 6. What is the answer, and how many table entries does a bag have at most?

Answer

The maximum weight is 16 ({0,2,5}\{0, 2, 5\} has 3+4+9=163 + 4 + 9 = 16); a bag has at most 6 independent subsets of its 3 vertices (out of 8 subsets).

Solution

Every bag contains vertex 0, so the table splits into "0 in the set" and "0 not in the set"; it is the classical way of solving a cycle by fixing one vertex. The program runs the four rules on the path decomposition (as a sequence of introduce and forget steps) and compares with brute force.

python · try it yourself
from itertools import combinations

w = [3, 1, 4, 1, 5, 9, 2]
n = len(w)
adj = {v: {(v - 1) % n, (v + 1) % n} for v in range(n)}
bags = [[0, i, i + 1] for i in range(1, n - 1)]
table, bag, biggest = {frozenset(): 0}, set(), 1
for B in bags + [[]]:
    for v in sorted(bag - set(B)):                 # forget
        new = {}
        for S, val in table.items():
            new[S - {v}] = max(new.get(S - {v}, -1), val)
        table, bag = new, bag - {v}
    for v in [x for x in B if x not in bag]:       # introduce
        new = dict(table)
        for S, val in table.items():
            if not adj[v] & S:
                new[S | {v}] = val + w[v]
        table, bag = new, bag | {v}
        biggest = max(biggest, len(table))
best = max(sum(w[v] for v in S) for r in range(n + 1) for S in combinations(range(n), r)
           if all(b not in adj[a] for a, b in combinations(S, 2)))
print("DP:", table[frozenset()], " brute force:", best, " largest table:", biggest)
DP: 16  brute force: 16  largest table: 6

The subsets of a bag {0,i,i+1}\{0, i, i+1\} that are independent in C7C_7 are ∅\emptyset, the three singletons, and {0,i}\{0, i\} and {0,i+1}\{0, i+1\} when those vertices are not neighbours of 0 ({i,i+1}\{i, i+1\} is an edge), so at most 6 (Independent Set on Bounded Treewidth).

Exercise 10: Parameterized or not?

Which of these reductions are parameterized reductions? (a) DOMINATING SET to SET COVER: universe VV, one set N[v]N[v] per vertex, same kk. (b) VERTEX COVER (G,k)(G, k) to INDEPENDENT SET (G,n−k)(G, n - k). (c) CLIQUE (G,k)(G, k) to CLIQUE (G′,k+1)(G', k + 1) where G′G' adds a universal vertex.

Answer

(a) yes; (b) no; (c) yes.

Solution

(a) A dominating set of size kk is exactly a choice of kk closed neighbourhoods covering VV; the parameter is unchanged and the map is polynomial. (b) is correct as a reduction but the new parameter n−kn - k is not bounded by a function of kk (Parameterized Reductions and W[1]-Hardness). (c) A kk-clique plus the universal vertex is a (k+1)(k+1)-clique, and a (k+1)(k+1)-clique in G′G' minus the universal vertex (or minus any vertex, if it does not use it) is a kk-clique of GG; k′=k+1≤g(k)k' = k + 1 \le g(k).

Exercise 11: A fast 3-coloring algorithm?

Someone claims a 2O(n)2^{O(\sqrt{n})} algorithm for 3-COLORING of arbitrary graphs on nn vertices. Which hypothesis does that refute? Would it be surprising for planar graphs?

Answer

On general sparse graphs it refutes ETH. For planar graphs a 2O(n)2^{O(\sqrt{n})} algorithm exists, and ETH says that is optimal.

Solution

3-COLORING has a linear reduction from 3-SAT: a formula with nn variables and m=O(n)m = O(n) clauses (after sparsification) becomes a graph with O(n+m)O(n + m) vertices and edges. A 2O(N)2^{O(\sqrt{N})} algorithm would then solve 3-SAT in 2O(n)=2o(n)2^{O(\sqrt{n})} = 2^{o(n)} time (Tight Lower Bounds from ETH and SETH). Planar graphs have treewidth O(n)O(\sqrt{n}), so the O∗(3t)O^*(3^{t}) coloring DP runs in 2O(n)2^{O(\sqrt{n})}; the reduction to planar graphs has quadratic blow-up, which is exactly why the planar lower bound is 2o(n)2^{o(\sqrt{n})} rather than 2o(n)2^{o(n)}.

Exercise 12: Sizes in split and list

A CNF formula has 40 variables and 200 clauses. How many vectors and which dimension does the split-and-list reduction produce? How many pairs does the naive OV algorithm inspect in the worst case, and what OV running time would beat brute force by a factor of 2102^{10}?

Answer

2202^{20} vectors per side, dimension 200; 2402^{40} pairs; an algorithm in time n2−εn^{2 - \varepsilon} with n=220n = 2^{20} and 20ε≥1020\varepsilon \ge 10, that is n1.5n^{1.5}, would take about 2302^{30} steps.

Solution

Each half has 20 variables, so 2202^{20} partial assignments per side, each a vector with one coordinate per clause (Orthogonal Vectors and the Split-and-List Reduction). The naive algorithm checks all 220⋅220=2402^{20} \cdot 2^{20} = 2^{40} pairs, as many as brute force has assignments. An O(n2−ε)O(n^{2 - \varepsilon}) algorithm costs 220(2−ε)2^{20(2 - \varepsilon)}; to save a factor 2102^{10} we need 20ε=1020 \varepsilon = 10, ε=12\varepsilon = \frac{1}{2}. SETH predicts that no fixed ε>0\varepsilon > 0 works for all clause widths.

Exercise 13: A negative triangle by min-plus

The symmetric weight matrix of 4 vertices is below. Compute C=W⋆WC = W \star W (over k≠i,jk \ne i, j) and use it to find a negative triangle.

text
      0    1    2    3
0     -    5   -4    2
1     5    -    3   -6
2    -4    3    -    1
3     2   -6    1    -
Answer

C01=min⁡(−4+3,2−6)=−4C_{01} = \min(-4 + 3, 2 - 6) = -4 and C01+w(1,0)=1≥0C_{01} + w(1, 0) = 1 \ge 0; but C12=min⁡(5−4,−6+1)=−5C_{12} = \min(5 - 4, -6 + 1) = -5 and C12+w(2,1)=−2<0C_{12} + w(2, 1) = -2 < 0: the triangle 1,3,21, 3, 2 has weight −6+1+3=−2-6 + 1 + 3 = -2. The triangle 0,2,30, 2, 3, of weight −4+1+2=−1-4 + 1 + 2 = -1, is negative too.

Solution

The program computes all of CC and checks every pair, then confirms with brute force over triples (APSP, Negative Triangle and Subcubic Equivalence).

python · try it yourself
from itertools import combinations

W = [[0, 5, -4, 2], [5, 0, 3, -6], [-4, 3, 0, 1], [2, -6, 1, 0]]
n = 4
for i, j in combinations(range(n), 2):
    k_best = min((k for k in range(n) if k not in (i, j)), key=lambda k: W[i][k] + W[k][j])
    c = W[i][k_best] + W[k_best][j]
    print(f"C[{i}][{j}] = {c:3} via {k_best};  C + w({j},{i}) = {c + W[j][i]:3}" + ("  <- negative" if c + W[j][i] < 0 else ""))
print("negative triangles:", [t for t in combinations(range(n), 3) if W[t[0]][t[1]] + W[t[1]][t[2]] + W[t[2]][t[0]] < 0])
C[0][1] =  -4 via 3;  C + w(1,0) =   1
C[0][2] =   3 via 3;  C + w(2,0) =  -1  <- negative
C[0][3] =  -3 via 2;  C + w(3,0) =  -1  <- negative
C[1][2] =  -5 via 3;  C + w(2,1) =  -2  <- negative
C[1][3] =   4 via 2;  C + w(3,1) =  -2  <- negative
C[2][3] =  -3 via 1;  C + w(3,2) =  -2  <- negative
negative triangles: [(0, 2, 3), (1, 2, 3)]

Test yourself

A vertex cover algorithm uses the branching vectors (1,4)(1, 4) and (2,3)(2, 3). What is its running time base?

  1. 1.3247
  2. 1.3803
  3. 1.4656
  4. 2

Which reduction is NOT parameterized?

  1. Dominating set to set cover with the same kk
  2. Vertex cover (G,k)(G, k) to independent set (G,n−k)(G, n - k)
  3. Clique (G,k)(G, k) to independent set in the complement with the same kk
  4. Clique (G,k)(G, k) to clique (G′,k+1)(G', k + 1) with a universal vertex added

What does a 2O(n)2^{O(\sqrt{n})} algorithm for 3-coloring all graphs on nn vertices refute?

  1. Nothing; such algorithms exist
  2. ETH
  3. P ≠\ne NP
  4. The 3SUM conjecture

In split and list, a formula with 40 variables gives OV instances with how many vectors per side?

  1. 40
  2. 2202^{20}
  3. 2402^{40}
  4. 200