uiz Space

May 2023 term · Advanced Algorithms · BSCS4021

Advanced Algorithms Quiz 2: 6 August 2023 (May 2023 term)

The IIT Madras BS Advanced Algorithms (Advanced Algorithms) Quiz 2 paper sat on 6 Aug 2023, in the May 2023 term: 15 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
15
Marks
50
Duration
120 min
Numerical
4
MCQ
8
MSQ
3

Updated

Official paper: IIT M DEGREE AN3 EXAM QPE3 06 Aug 2023 · No negative marking.

Question 1

+3 marksNumerical answer

For the following sets of timings of dance classes, figure out what is the largest number of classes that you can attend in a conflict-free fashion:

The number of classes is N = 9. The timings of the classes are given by:

  1. [1 - 5]
  2. [6 - 10]
  3. [11- 15]
  4. [16 - 20]
  5. [2 - 8]
  6. [3 - 8]
  7. [2 - 7]
  8. [9 - 12]
  9. [13 - 17]
Show answer

Correct answer: 4

Question 2

+3 marksNumerical answer

Consider 4 sets as follows: W={w1,w2,w3}W = \{w_1, w_2, w_3\}, X={x1,x2}X = \{x_1, x_2\}, Y={y1,y2,y3}Y = \{y_1, y_2, y_3\} and Z={z1,z2}Z = \{z_1, z_2\}.

Given capacity constraints are as follows:

c(w2)=c(y1)=c(y3)=1,c(w_2) = c(y_1) = c(y_3) = 1,

c(w1)=c(w3)=c(x2)=c(y2)=c(z1)=2,c(w_1) = c(w_3) = c(x_2) = c(y_2) = c(z_1) = 2,

c(x1)=c(z2)=3c(x_1) = c(z_2) = 3

c(wi,xi)=1, for all wi∈W and all xi∈X,c(w_i, x_i) = 1, \text{ for all } w_i \in W \text{ and all } x_i \in X,

c(yi,zi)=1, for all yi∈Y and all zi∈Zc(y_i, z_i) = 1, \text{ for all } y_i \in Y \text{ and all } z_i \in Z

c(x1,y1)=1,c(x1,y2)=2,c(x1,y3)=1c(x_1, y_1) = 1, c(x_1, y_2) = 2, c(x_1, y_3) = 1

c(x2,y1)=0,c(x2,y2)=2,c(x2,y3)=1.c(x_2, y_1) = 0, c(x_2, y_2) = 2, c(x_2, y_3) = 1.

Identify the size of a largest collection of 4-tuples from the sets W,X,YW, X, Y and ZZ satisfying the given constraints

Show answer

Correct answer: 4

Question 3

+2 marksOne correct option

Let GG be a simple, undirected, unweighted graph.

We use V(G)V(G) to denote the vertex set of GG and E(G)E(G) to denote the edge set of GG.

Recall that if we have an empty graph (i.e, a graph where V(G)=E(G)=∅V(G) = E(G) = \emptyset), then by convention it (vacuously) satisfies the properties suggested in the given subquestions

Consider the set system (U,F)(U, \mathcal{F}) defined as follows.

  • The universe UU is V(G)V(G).
  • A subset of vertices S⊆V(G)S \subseteq V(G) belongs to F\mathcal{F} if the subgraph induced by SS has maximum degree three.

Which of the following properties is/are NOT satisfied by F\mathcal{F}?

  1. A

    Non-emptiness

  2. B

    Heredity

  3. C

    The Exchange Property

  4. D

    None of these

Show answer

Correct answer

  • C

    The Exchange Property

Question 4

+2 marksOne or more correct options

Let GG be a simple, undirected, unweighted graph.

We use V(G)V(G) to denote the vertex set of GG and E(G)E(G) to denote the edge set of GG.

Recall that if we have an empty graph (i.e, a graph where V(G)=E(G)=∅V(G) = E(G) = \emptyset), then by convention it (vacuously) satisfies the properties suggested in the given subquestions

Consider the set system (U,F)(U, \mathcal{F}) defined as follows.

  • The universe UU is V(G)V(G).
  • A subset of vertices S⊆V(G)S \subseteq V(G) belongs to F\mathcal{F} if the subgraph induced by SS has minimum degree three.

Which of the following properties is/are NOT satisfied by F\mathcal{F}?

Select all that apply.

  1. A

    Non-emptiness

  2. B

    Heredity

  3. C

    The Exchange Property

  4. D

    None of these

Show answer

Correct answers

  • B

    Heredity

  • C

    The Exchange Property

Question 5

+3 marksOne correct option

There are NN stones, numbered 1,2,…,N1, 2, \ldots, N. For each (1⩽i⩽N)(1 \leqslant i \leqslant N), the height of stone ii is hih_i. Assume these heights are stored in an array HH.

There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone NN:

  • If the frog is currently on Stone ii, jump to Stone i+1i+1 or Stone i+2i+2.
  • Here, a cost of ∣hi−hj∣|h_i - h_j| is incurred, where jj is the stone to land on.

Our goal is to find the minimum possible total cost incurred before the frog reaches Stone NN.

Towards solving this problem, note that the frog, can jump to only (i + 1) or (i + 2) from a position i. We will now try to define a recurrence that leads us to the solution.

For all 1⩽i⩽N1 \leqslant i \leqslant N, define dp[i] as the minimum cost we can achieve to reach stone i. For our base cases, note that we have the following:

  • dp[0] = 0 and
  • dp[1] = abs(H[1] − H[0]) as if we are on the second stone (0 based indexing), there is only one way to reach it i.e from the first stone.

Based on the above data, answer the given subquestions.

Which of the following is a valid recurrence for dp[i]?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 6

+2 marksNumerical answer

There are NN stones, numbered 1,2,…,N1, 2, \ldots, N. For each (1⩽i⩽N)(1 \leqslant i \leqslant N), the height of stone ii is hih_i. Assume these heights are stored in an array HH.

There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone NN:

  • If the frog is currently on Stone ii, jump to Stone i+1i+1 or Stone i+2i+2.
  • Here, a cost of ∣hi−hj∣|h_i - h_j| is incurred, where jj is the stone to land on.

Our goal is to find the minimum possible total cost incurred before the frog reaches Stone NN.

Towards solving this problem, note that the frog, can jump to only (i + 1) or (i + 2) from a position i. We will now try to define a recurrence that leads us to the solution.

For all 1⩽i⩽N1 \leqslant i \leqslant N, define dp[i] as the minimum cost we can achieve to reach stone i. For our base cases, note that we have the following:

  • dp[0] = 0 and
  • dp[1] = abs(H[1] − H[0]) as if we are on the second stone (0 based indexing), there is only one way to reach it i.e from the first stone.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 40

Question 7

+2 marksNumerical answer

There are NN stones, numbered 1,2,…,N1, 2, \ldots, N. For each (1⩽i⩽N)(1 \leqslant i \leqslant N), the height of stone ii is hih_i. Assume these heights are stored in an array HH. We are also given an additional parameter K⩽N−1K \leqslant N-1 which denotes the maximum jump length.

There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone NN:

  • If the frog is currently on Stone ii, jump to one of the following: Stone i+1,i+2,…,i+Ki+1, i+2, \ldots, i+K.
  • Here, a cost of ∣hi−hj∣|h_i - h_j| is incurred, where jj is the stone to land on.

Our goal is to find the minimum possible total cost incurred before the frog reaches Stone NN.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 40

Question 8

+3 marksOne or more correct options

There are NN stones, numbered 1,2,…,N1, 2, \ldots, N. For each (1⩽i⩽N)(1 \leqslant i \leqslant N), the height of stone ii is hih_i. Assume these heights are stored in an array HH. We are also given an additional parameter K⩽N−1K \leqslant N-1 which denotes the maximum jump length.

There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone NN:

  • If the frog is currently on Stone ii, jump to one of the following: Stone i+1,i+2,…,i+Ki+1, i+2, \ldots, i+K.
  • Here, a cost of ∣hi−hj∣|h_i - h_j| is incurred, where jj is the stone to land on.

Our goal is to find the minimum possible total cost incurred before the frog reaches Stone NN.

Based on the above data, answer the given subquestions.

Consider the following program that attempts to solve this problem.

For all 1⩽i⩽N1 \leqslant i \leqslant N, define dp[i] as the minimum cost we can achieve to reach stone i. We set dp[0] = 0 and dp[i] to infinity for all 1⩽i⩽N−11 \leqslant i \leqslant N-1.

We then propose to populate dp according to the code below.

c
for (int i = 0; i < n; i++) { // i represents the stone the frog is currently at.
for (int j = i + 1; j ≤ i + k; j++) { // j represents a potential stone
for the frog to jump to.
// Storing the total minimum cost to reach stone j from stone i.
dp[j] = min(dp[j], dp[i] + abs(H[j] - H[i]));
}
}

Which of the following statements is true about the code snippet above? Select all that apply.

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • C

Question 9

+3 marksOne correct option

Which of the following statements is true?
Statement 1: For every graph G and every maximum flow on G, there always exists an edge such that increasing the capacity on that edge will increase the maximum flow that’s possible in the graph.
Statement 2: Suppose the maximum (s, t)-flow of some graph has value f. Now we increase the capacity of every edge by 1. Then the maximum (s, t)-flow in this modified graph will have value at most f + 1.

  1. A

    Statement 1

  2. B

    Statement 2

  3. C

    Both statements

  4. D

    Neither statement

Show answer

Correct answer

  • D

    Neither statement

Question 10

+2 marksOne correct option
  1. A

    If there is any edge that is not saturated to full capacity, then we can conclude that f is not a maximum flow.

  2. B

    If the residual graph does not have any augmenting paths then f is a maximum flow.

  3. C

    If the value of the flow f is not the sum of the capacities of the edges coming out of the source s then f is not a maximum flow.

  4. D

    If the value of the flow f is not the sum of the capacities of the edges coming into the sink t then f is not a maximum flow.

Show answer

Correct answer

  • B

    If the residual graph does not have any augmenting paths then f is a maximum flow.

Question 11

+5 marksOne or more correct options

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • C
  • E

Question 12

+5 marksOne correct option

Consider the following definitions:

  • A vertex cover is a subset SS of V(G)V(G) such that for all (u,v)∈E(G)(u,v) \in E(G), S∩{u,v}≠∅S \cap \{u,v\} \neq \emptyset.
  • An independent set is a subset SS of V(G)V(G) such that for all (u,v)∈S(u,v) \in S, {u,v}∉E(G)\{u,v\} \notin E(G).
  • A maximum matching in GG is a largest collection of edges F⊆E(G)F \subseteq E(G) such that no two edges in FF have a common endpoint.
  • A feedback vertex set is a subset SS of V(G)V(G) such that G∖SG \setminus S is acyclic.
  • An odd cycle transversal is a subset SS of V(G)V(G) such that G∖SG \setminus S is bipartite.

Which of the following is not a valid lower bound for the size of a minimum vertex cover of a graph GG?

  1. A

    the size of a maximum independent set in G

  2. B

    the size of a maximum matching in G

  3. C

    the size of a minimum feedback vertex set in G

  4. D

    the size of a minimum odd cycle transversal G

Show answer

Correct answer

  • A

    the size of a maximum independent set in G

Question 13

+5 marksOne correct option
  1. A

    Yes, because we can reduce 3SAT to NICE SET.

  2. B

    Yes, because we can reduce NICE SET to 3SAT.

  3. C

    No, because we can reduce NICE SET to MAX FLOW.

  4. D

    No, because we can reduce MAX FLOW to NICE SET.

Show answer

Correct answer

  • A

    Yes, because we can reduce 3SAT to NICE SET.

Question 14

+5 marksOne correct option
  1. A

    No, because the problem can be solved in polynomial time.

  2. B

    Yes, because we can reduce 3SAT to ALL-or-NOTHING-3SAT.

  3. C

    Yes, because we can reduce ALL-or-NOTHING-3SAT to 3SAT.

Show answer

Correct answer

  • A

    No, because the problem can be solved in polynomial time.

Question 15

+5 marksOne correct option

Consider a different rounding strategy for the LP relaxation of the vertex cover problem. Instead of rounding up every vertex whose value is at least 0.50.5 after running the LP, we do the following:

We look at every edge, and then we round up the variable of the endpoint with the highest value, where in case of ties we take the endpoint with the highest index.

In other words, if the vertex set is V={v1,…,vn}V = \{v_1, \ldots, v_n\} and we denote the associated variable of viv_i by xix_i then the cover CC is computed as follows:

C:={vi∈V:there is an edge (vi,vj) such that (xi>xj) or (xi=xj and i>j)}C := \{v_i \in V : \text{there is an edge } (v_i, v_j) \text{ such that } (x_i > x_j) \text{ or } (x_i = x_j \text{ and } i > j)\}

Which statement is true?

  1. A

    This does not work, because we might report an invalid solution.

  2. B

    This gives a valid solution, but the approximation ratio becomes worse.

  3. C

    This gives a valid solution, and in fact the solution is always exactly the same as in the original rounding scheme.

  4. D

    This gives a valid solution. We sometimes report a better solution than in the original rounding scheme, but the approximation ratio of the algorithm is still more than 2 - ϵ for any ϵ > 0.

  5. E

    This gives a valid solution, and the approximation ratio of the algorithm becomes 3/2.

Show answer

Correct answer

  • D

    This gives a valid solution. We sometimes report a better solution than in the original rounding scheme, but the approximation ratio of the algorithm is still more than 2 - ϵ for any ϵ > 0.