uiz Space

September 2023 term · Advanced Algorithms · BSCS4021

Advanced Algorithms Quiz 2: 3 December 2023 (September 2023 term)

The IIT Madras BS Advanced Algorithms (Advanced Algorithms) Quiz 2 paper sat on 3 Dec 2023, in the September 2023 term: 20 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
20
Marks
50
Duration
120 min
Numerical
3
MCQ
17

Updated

Official paper: IIT M DEGREE AN2 EXAM QDB2 03 Dec 2023 · No negative marking.

Question 1

+2 marksNumerical answer

You are given a sequence of integers aa of length 2n2n. You have to split these 2n2n integers into nn pairs; each pair will represent the coordinates of a point on a plane. Each number from the sequence aa should become the xx or yy coordinate of exactly one point. Note that some points can be equal.

After the points are formed, you have to choose a path ss that starts from one of these points, ends at one of these points, and visits all nn points at least once.

The length of path ss is the sum of distances between all adjacent points on the path. In this problem, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.

Your task is to form nn points and choose a path ss in such a way that the length of path ss is minimized.

For example, if the given sequence is 15, 1, 10, 5, then you can form points (10,1)(10, 1) and (15,5)(15, 5) and start the path ss from the first point and end it at the second point. Then the length of the path will be ∣10−15∣+∣1−5∣=5+4=9|10 - 15| + |1 - 5| = 5 + 4 = 9. It can be shown that this is the best possible.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 20

Question 2

+2 marksNumerical answer

You are given a sequence of integers aa of length 2n2n. You have to split these 2n2n integers into nn pairs; each pair will represent the coordinates of a point on a plane. Each number from the sequence aa should become the xx or yy coordinate of exactly one point. Note that some points can be equal.

After the points are formed, you have to choose a path ss that starts from one of these points, ends at one of these points, and visits all nn points at least once.

The length of path ss is the sum of distances between all adjacent points on the path. In this problem, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.

Your task is to form nn points and choose a path ss in such a way that the length of path ss is minimized.

For example, if the given sequence is 15, 1, 10, 5, then you can form points (10,1)(10, 1) and (15,5)(15, 5) and start the path ss from the first point and end it at the second point. Then the length of the path will be ∣10−15∣+∣1−5∣=5+4=9|10 - 15| + |1 - 5| = 5 + 4 = 9. It can be shown that this is the best possible.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 2

Question 3

+3 marksOne correct option

You are given a sequence of integers aa of length 2n2n. You have to split these 2n2n integers into nn pairs; each pair will represent the coordinates of a point on a plane. Each number from the sequence aa should become the xx or yy coordinate of exactly one point. Note that some points can be equal.

After the points are formed, you have to choose a path ss that starts from one of these points, ends at one of these points, and visits all nn points at least once.

The length of path ss is the sum of distances between all adjacent points on the path. In this problem, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.

Your task is to form nn points and choose a path ss in such a way that the length of path ss is minimized.

For example, if the given sequence is 15, 1, 10, 5, then you can form points (10,1)(10, 1) and (15,5)(15, 5) and start the path ss from the first point and end it at the second point. Then the length of the path will be ∣10−15∣+∣1−5∣=5+4=9|10 - 15| + |1 - 5| = 5 + 4 = 9. It can be shown that this is the best possible.

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 4

+3 marksOne correct option

You are given a sequence of integers aa of length 2n2n. You have to split these 2n2n integers into nn pairs; each pair will represent the coordinates of a point on a plane. Each number from the sequence aa should become the xx or yy coordinate of exactly one point. Note that some points can be equal.

After the points are formed, you have to choose a path ss that starts from one of these points, ends at one of these points, and visits all nn points at least once.

The length of path ss is the sum of distances between all adjacent points on the path. In this problem, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.

Your task is to form nn points and choose a path ss in such a way that the length of path ss is minimized.

For example, if the given sequence is 15, 1, 10, 5, then you can form points (10,1)(10, 1) and (15,5)(15, 5) and start the path ss from the first point and end it at the second point. Then the length of the path will be ∣10−15∣+∣1−5∣=5+4=9|10 - 15| + |1 - 5| = 5 + 4 = 9. It can be shown that this is the best possible.

Based on the above data, answer the given subquestions.

Let a1,…,a2na_1, \ldots, a_{2n} be the input sequence in sorted (ascending) order. In particular, the minimum element is a1a_1, the maximum element is a2na_{2n}, and the element ana_n is at least as large as the first n−1n - 1 elements, and an+1a_{n+1} is at most the value of the last n−1n - 1 elements. No matter how we form the points as described in the problem, the resulting path will have a length of at least:

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

Correct answer

  • C

Question 5

+3 marksOne correct option

You are given a sequence of integers aa of length 2n2n. You have to split these 2n2n integers into nn pairs; each pair will represent the coordinates of a point on a plane. Each number from the sequence aa should become the xx or yy coordinate of exactly one point. Note that some points can be equal.

After the points are formed, you have to choose a path ss that starts from one of these points, ends at one of these points, and visits all nn points at least once.

The length of path ss is the sum of distances between all adjacent points on the path. In this problem, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.

Your task is to form nn points and choose a path ss in such a way that the length of path ss is minimized.

For example, if the given sequence is 15, 1, 10, 5, then you can form points (10,1)(10, 1) and (15,5)(15, 5) and start the path ss from the first point and end it at the second point. Then the length of the path will be ∣10−15∣+∣1−5∣=5+4=9|10 - 15| + |1 - 5| = 5 + 4 = 9. It can be shown that this is the best possible.

Based on the above data, answer the given subquestions.

  1. A
  2. B
Show answer

Correct answer

  • A

Question 6

+2 marksNumerical answer

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 28

Question 7

+2 marksOne correct option

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

  1. A

    This solution is definitely not optimal

  2. B

    This solution may or may not be optimal, depends on the values of the payouts.

Show answer

Correct answer

  • A

    This solution is definitely not optimal

Question 8

+3 marksOne correct option

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

Let L(i)L(i) be the cash payout of playing the lottery on day i∈{1,…,n}i \in \{1, \ldots, n\}. We need to keep track of most recent two plays (or equivalently, restrictions on future plays). Let x(i,j)x(i, j) be maximum lottery winnings playing on suffix of days from ii to nn, assuming play on day ii and next allowable play is on day i+ji + j for i∈{1,…,n}i \in \{1, \ldots, n\} and j∈{1,…,6}j \in \{1, \ldots, 6\}. What is the final answer?

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

Correct answer

  • A

Question 9

+3 marksOne correct option

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 10

+3 marksOne correct option

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

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

Correct answer

  • D

Question 11

+3 marksOne correct option

Tina stumbles upon a lottery chart dropped by a time traveler from the future, which lists winning lottery numbers and positive integer cash payouts for the next nn days. Tina wants to use this information to make money, but is worried if she plays winning numbers every day, lottery organizers will get suspicious. As such, she decides to play the lottery infrequently: at most twice in any seven day period.

In this problem, we will build up towards an O(n)O(n)-time algorithm to determine the maximum amount of lottery winnings Tina can win in the next nn days by playing the lottery infrequently.

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 12

+2 marksOne correct option

Let G=(V,E)G = (V, E) be a graph. A cut in GG is a partition of VV into two sets. Let S⊆VS \subseteq V be a subset of vertices. The cost of the cut (S,V\S)(S, V \backslash S), denoted by cost(S)(S), equals the number of edges between SS and V\SV \backslash S, i.e., the size of the set {{x,y}∈E∣x∈S,y∈V\S}\{\{x, y\} \in E \mid x \in S, y \in V \backslash S\}. The edges that have one endpoint in SS and the other in V\SV \backslash S are said to cross the cut.

The Maximum Cut Problem takes a graph G=(V,E)G = (V, E) as input and the objective is to find a cut with maximum cost.

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 13

+2 marksOne correct option

Let G=(V,E)G = (V, E) be a graph. A cut in GG is a partition of VV into two sets. Let S⊆VS \subseteq V be a subset of vertices. The cost of the cut (S,V\S)(S, V \backslash S), denoted by cost(S)(S), equals the number of edges between SS and V\SV \backslash S, i.e., the size of the set {{x,y}∈E∣x∈S,y∈V\S}\{\{x, y\} \in E \mid x \in S, y \in V \backslash S\}. The edges that have one endpoint in SS and the other in V\SV \backslash S are said to cross the cut.

The Maximum Cut Problem takes a graph G=(V,E)G = (V, E) as input and the objective is to find a cut with maximum cost.

Based on the above data, answer the given subquestions.

What is the maximum possible value of the cost of the maximum cut?

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

Correct answer

  • A

Question 14

+2 marksOne correct option

Let G=(V,E)G = (V, E) be a graph. A cut in GG is a partition of VV into two sets. Let S⊆VS \subseteq V be a subset of vertices. The cost of the cut (S,V\S)(S, V \backslash S), denoted by cost(S)(S), equals the number of edges between SS and V\SV \backslash S, i.e., the size of the set {{x,y}∈E∣x∈S,y∈V\S}\{\{x, y\} \in E \mid x \in S, y \in V \backslash S\}. The edges that have one endpoint in SS and the other in V\SV \backslash S are said to cross the cut.

The Maximum Cut Problem takes a graph G=(V,E)G = (V, E) as input and the objective is to find a cut with maximum cost.

Based on the above data, answer the given subquestions.

For q⩾1q \geqslant 1, a qq-approximation algorithm for maximum cut is an algorithm that is guaranteed to produce a cut whose cost is at least 1q\frac{1}{q} of the cost of the optimal cut of the input instance.

Suppose we can devise an algorithm that, given a graph GG on mm edges, is guaranteed to find a cut whose cost is at least m2\frac{m}{2}. Such an algorithm would be:

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

Correct answer

  • B

Question 15

+2 marksOne correct option

Let G=(V,E)G = (V, E) be a graph. A cut in GG is a partition of VV into two sets. Let S⊆VS \subseteq V be a subset of vertices. The cost of the cut (S,V\S)(S, V \backslash S), denoted by cost(S)(S), equals the number of edges between SS and V\SV \backslash S, i.e., the size of the set {{x,y}∈E∣x∈S,y∈V\S}\{\{x, y\} \in E \mid x \in S, y \in V \backslash S\}. The edges that have one endpoint in SS and the other in V\SV \backslash S are said to cross the cut.

The Maximum Cut Problem takes a graph G=(V,E)G = (V, E) as input and the objective is to find a cut with maximum cost.

Based on the above data, answer the given subquestions.

Consider the following trivial randomized algorithm that does not depend on the kind of the graph:

  • Place each vertex uu in SS or TT independently and uniformly at random.

For this randomized method, it makes sense to talk about the expected value of the size of the cut, that we denote by E[ size of cut]. To analyze the expected size of the cut we will use the linearity of expectation:

E[αx+βx]=αE[x]+βE[x]E[\alpha x + \beta x] = \alpha E[x] + \beta E[x]

First, consider the following variable XeX_e for a fixed edge ee:

Xe={1if e is in the cut0otherwiseX_e = \begin{cases} 1 & \text{if e is in the cut} \\ 0 & \text{otherwise} \end{cases}

What is the expected value of XeX_e?

  1. A

    1/2

  2. B

    1/4

  3. C

    1

  4. D

    2

Show answer

Correct answer

  • A

    1/2

Question 16

+2 marksOne correct option

Let G=(V,E)G = (V, E) be a graph. A cut in GG is a partition of VV into two sets. Let S⊆VS \subseteq V be a subset of vertices. The cost of the cut (S,V\S)(S, V \backslash S), denoted by cost(S)(S), equals the number of edges between SS and V\SV \backslash S, i.e., the size of the set {{x,y}∈E∣x∈S,y∈V\S}\{\{x, y\} \in E \mid x \in S, y \in V \backslash S\}. The edges that have one endpoint in SS and the other in V\SV \backslash S are said to cross the cut.

The Maximum Cut Problem takes a graph G=(V,E)G = (V, E) as input and the objective is to find a cut with maximum cost.

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 17

+3 marksOne correct option

Recall the max-flow problem: for a directed graph G(V,E)G(V, E) with non-negative capacities cec_e for every e∈Ee \in E and two special vertices ss (source, with no incoming edges) and tt (sink, with no outgoing edges), a flow in GG is an assignment f:E→R≥0f : E \rightarrow \mathbb{R}_{\geq 0} such that fe≤cef_e \leq c_e for every edge and for every vertex v∈V,∑(u,v)∈Ef((u,v))=∑(v,u)∈Ef((v,u))v \in V, \sum_{(u,v) \in E} f((u,v)) = \sum_{(v,u) \in E} f((v,u)). The task is to find a maximum flow ff i.e., a flow ff such that ∑(s,u)∈Ef((s,u))\sum_{(s,u) \in E} f((s,u)) is maximized.

Given an instance (G;s,t,c)(G; s, t, c), we attempt here to design a LP whose optimal value is equal to the maximum flow in the graph GG. There is a variable xuvx_{uv} for all (u,v)∈E(u, v) \in E. Note that for any pair of vertices that is not an edge, we do not introduce any variable corresponding to it.

max⁡∑uxut∀e=(u,v)∈E,xuv⩽ce∀v∉{s,t},∑uxuv=∑wxvw∀e=(u,v)∈E,xuv⩾0\begin{aligned} &\max \sum_u x_{ut} \\ &\forall e = (u,v) \in E, x_{uv} \leqslant c_e \\ &\forall v \notin \{s,t\}, \sum_u x_{uv} = \sum_w x_{vw} \\ &\forall e = (u,v) \in E, x_{uv} \geqslant 0 \end{aligned}

Is the LP above a valid formulation for computing the maximum flow in GG?

  1. A
  2. B
  3. C
Show answer

Correct answer

  • A

Question 18

+3 marksOne correct option

The EXACT-COVER-BY-3-SETS problem is defined as the following: given a finite set XX with ∣X∣=3q|X| = 3q and a collection CC of 3-element subsets of XX, does CC contain an exact cover for XX, that is, a subcollection C′⊆CC' \subseteq C such that every element of XX occurs in exactly one member of C′C'?

The EXACT-COVER-BY-4-SETS problem is defined as the following: given a finite set XX with ∣X∣=4q|X| = 4q and a collection CC of 4-element subsets of XX, does CC contain an exact cover for XX, that is, a subcollection C′⊆CC' \subseteq C such that every element of XX occurs in exactly one member of C′C'?

Given that EXACT-COVER-BY-3-SETS is NP-Complete, is EXACT-COVER-BY-4-SETS also NP-Complete?

  1. A

    Yes, because there is a reduction from EXACT-COVER-BY-3-SETS to EXACT- COVER-BY-4-SETS.

  2. B

    Yes, because there is a reduction from EXACT-COVER-BY-4-SETS to EXACT- COVER-BY-3-SETS.

  3. C

    EXACT-COVER-BY-4-SETS may or may not be NP-Complete.

Show answer

Correct answer

  • A

    Yes, because there is a reduction from EXACT-COVER-BY-3-SETS to EXACT- COVER-BY-4-SETS.

Question 19

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 20

+2 marksOne correct option

Say problem X reduces to problem Y. Which of the following can we infer?

  1. A

    If X can be solved in polynomial time, then so can Y.

  2. B

    X can be solved in polynomial time if and only if Y can be solved in polynomial time.

  3. C

    If X cannot be solved in polynomial time, then neither can Y.

  4. D

    If Y cannot be solved in polynomial time, then neither can X.

Show answer

Correct answer

  • C

    If X cannot be solved in polynomial time, then neither can Y.