uiz Space

September 2023 term · Advanced Algorithms · BSCS4021

Advanced Algorithms End Term: 24 December 2023, Set ADI4 (September 2023 term)

The IIT Madras BS Advanced Algorithms (Advanced Algorithms) End Term paper sat on 24 Dec 2023, in the September 2023 term, set ADI4: 24 questions for 50 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
24
Marks
50
Duration
180 min
Numerical
5
MCQ
19

Updated

Official paper: IIT M DEGREE FN EXAM FDB1 24 Dec 2023 · No negative marking.

Question 1

+2 marksNumerical answer

In one term of an academic program, we have nn days. Students have to earn at least PP credits during these nn days to remain in the program. There are two ways to earn points — completing practical tasks and attending lessons. For each task, a student earns TT points, and for each lesson, a student earns LL points.

Practical tasks are unlocked “each week” as the term goes on: the first task is unlocked on day 1 (and can be completed on any day from 1 to nn), the second task is unlocked on day 8 (and can be completed on any day from 8 to nn), the third task is unlocked on day 15, and so on.

Every day from 1 to nn, there is a lesson which can be attended by the students of the program. And every day, students choose whether to study or to rest the whole day. When a student decides to study, he or she attends a lesson and can complete no more than 2 tasks, which are already unlocked and not completed yet. If a student rests the whole day, he skips a lesson and ignores tasks.

Students naturally wants to have as many days off as possible, i. e. they want to maximize the number of rest days. Let's calculate this maximum.

As an example: if n=100,P=20,L=1n = 100, P = 20, L = 1 and T=10T = 10, then by studying only on day 42 we attend a lesson gives (1 point), and can solve 2 out of 6 available tasks to get another 20 points. This is necessary and sufficient, and leads to 99 rest days.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 13

Question 2

+2 marksNumerical answer

In one term of an academic program, we have nn days. Students have to earn at least PP credits during these nn days to remain in the program. There are two ways to earn points — completing practical tasks and attending lessons. For each task, a student earns TT points, and for each lesson, a student earns LL points.

Practical tasks are unlocked “each week” as the term goes on: the first task is unlocked on day 1 (and can be completed on any day from 1 to nn), the second task is unlocked on day 8 (and can be completed on any day from 8 to nn), the third task is unlocked on day 15, and so on.

Every day from 1 to nn, there is a lesson which can be attended by the students of the program. And every day, students choose whether to study or to rest the whole day. When a student decides to study, he or she attends a lesson and can complete no more than 2 tasks, which are already unlocked and not completed yet. If a student rests the whole day, he skips a lesson and ignores tasks.

Students naturally wants to have as many days off as possible, i. e. they want to maximize the number of rest days. Let's calculate this maximum.

As an example: if n=100,P=20,L=1n = 100, P = 20, L = 1 and T=10T = 10, then by studying only on day 42 we attend a lesson gives (1 point), and can solve 2 out of 6 available tasks to get another 20 points. This is necessary and sufficient, and leads to 99 rest days.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 37

Question 3

+2 marksOne correct option

In one term of an academic program, we have nn days. Students have to earn at least PP credits during these nn days to remain in the program. There are two ways to earn points — completing practical tasks and attending lessons. For each task, a student earns TT points, and for each lesson, a student earns LL points.

Practical tasks are unlocked “each week” as the term goes on: the first task is unlocked on day 1 (and can be completed on any day from 1 to nn), the second task is unlocked on day 8 (and can be completed on any day from 8 to nn), the third task is unlocked on day 15, and so on.

Every day from 1 to nn, there is a lesson which can be attended by the students of the program. And every day, students choose whether to study or to rest the whole day. When a student decides to study, he or she attends a lesson and can complete no more than 2 tasks, which are already unlocked and not completed yet. If a student rests the whole day, he skips a lesson and ignores tasks.

Students naturally wants to have as many days off as possible, i. e. they want to maximize the number of rest days. Let's calculate this maximum.

As an example: if n=100,P=20,L=1n = 100, P = 20, L = 1 and T=10T = 10, then by studying only on day 42 we attend a lesson gives (1 point), and can solve 2 out of 6 available tasks to get another 20 points. This is necessary and sufficient, and leads to 99 rest days.

Based on the above data, answer the given subquestions.

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

Correct answer

  • D

Question 4

+2 marksOne correct option

In one term of an academic program, we have nn days. Students have to earn at least PP credits during these nn days to remain in the program. There are two ways to earn points — completing practical tasks and attending lessons. For each task, a student earns TT points, and for each lesson, a student earns LL points.

Practical tasks are unlocked “each week” as the term goes on: the first task is unlocked on day 1 (and can be completed on any day from 1 to nn), the second task is unlocked on day 8 (and can be completed on any day from 8 to nn), the third task is unlocked on day 15, and so on.

Every day from 1 to nn, there is a lesson which can be attended by the students of the program. And every day, students choose whether to study or to rest the whole day. When a student decides to study, he or she attends a lesson and can complete no more than 2 tasks, which are already unlocked and not completed yet. If a student rests the whole day, he skips a lesson and ignores tasks.

Students naturally wants to have as many days off as possible, i. e. they want to maximize the number of rest days. Let's calculate this maximum.

As an example: if n=100,P=20,L=1n = 100, P = 20, L = 1 and T=10T = 10, then by studying only on day 42 we attend a lesson gives (1 point), and can solve 2 out of 6 available tasks to get another 20 points. This is necessary and sufficient, and leads to 99 rest days.

Based on the above data, answer the given subquestions.

If we have to pick q continuous rest days, it is optimal for us to choose:

  1. A

    the first q days of the term

  2. B

    the last q days of the term

  3. C

    the middle q days of the term

  4. D

    it makes no difference

Show answer

Correct answer

  • A

    the first q days of the term

Question 5

+2 marksOne correct option
  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 6

+3 marksOne correct option

Choose the correct options:

  1. A
  2. B
  3. C
Show answer

Correct answer

  • A

Question 7

+3 marksOne correct option

Consider the following instance of Set Cover problem:

  • Universe U={a,b,c}\mathcal{U} = \{a, b, c\}
  • Family F={S1={a,b},S2={a},S3={b},S4={c}}\mathcal{F} = \{S_1 = \{a, b\}, S_2 = \{a\}, S_3 = \{b\}, S_4 = \{c\}\}

We build the following DP table for finding the Minimum Set Cover.

Π(X,j)\Pi(X, j) : minimum number of sets from S1,…,SjS_1, \ldots, S_j required to cover XX

j\Xj \backslash Xϕ\phi{a}\{a\}{b}\{b\}{c}\{c\}{a,b}\{a,b\}{a,c}\{a,c\}{b,c}\{b,c\}{a,b,c}\{a,b,c\}
00∞\infty∞\infty∞\infty∞\infty∞\infty∞\infty∞\infty
1011∞\infty1∞\infty∞\infty∞\infty
2011∞\infty1∞\infty∞\infty∞\infty
3011∞\infty1∞\infty∞\infty∞\infty
40111122?

What is the missing entry?

  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    3

Show answer

Correct answer

  • C

    2

Question 8

+2 marksOne correct option

You have been given a R × C chessboard, with a list of squares cut out. This problem will involve placing rooks on a chessboard, so that they cannot attack each other. For a rook to attack a target piece, it must share the same row or column as the target.
Find the maximum number of rooks that can be placed on the chessboard, such that no pair of rooks can attack each other.
Rooks cannot be placed on cut out squares. The cut out squares do not affect where the rooks can attack.
Based on the above data, answer the given subquestions.

What is the answer if R = C = N and there are no cut out squares?

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

Correct answer

  • C

Question 9

+2 marksOne correct option

You have been given a R × C chessboard, with a list of squares cut out. This problem will involve placing rooks on a chessboard, so that they cannot attack each other. For a rook to attack a target piece, it must share the same row or column as the target.
Find the maximum number of rooks that can be placed on the chessboard, such that no pair of rooks can attack each other.
Rooks cannot be placed on cut out squares. The cut out squares do not affect where the rooks can attack.
Based on the above data, answer the given subquestions.

What is the answer if R = C = N and all the squares on the topmost row and rightmost column (i.e, a L-shape) are cut out?

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

Correct answer

  • D

Question 10

+2 marksOne correct option

You have been given a R × C chessboard, with a list of squares cut out. This problem will involve placing rooks on a chessboard, so that they cannot attack each other. For a rook to attack a target piece, it must share the same row or column as the target.
Find the maximum number of rooks that can be placed on the chessboard, such that no pair of rooks can attack each other.
Rooks cannot be placed on cut out squares. The cut out squares do not affect where the rooks can attack.
Based on the above data, answer the given subquestions.

Consider the following bipartite graph: the set A is composed of elements corresponding to every row of the board, while set B consists of the columns. For each row add edges to every column if the corresponding square is not cut out of the board. What does the answer correspond to in this graph?

  1. A

    the maximum vertex degree

  2. B

    the number of edges in a minimum spanning forest

  3. C

    the size of a maximum matching

  4. D

    none of these

Show answer

Correct answer

  • C

    the size of a maximum matching

Question 11

+2 marksOne correct option

You have been given a R × C chessboard, with a list of squares cut out. This problem will involve placing rooks on a chessboard, so that they cannot attack each other. For a rook to attack a target piece, it must share the same row or column as the target.
Find the maximum number of rooks that can be placed on the chessboard, such that no pair of rooks can attack each other.
Rooks cannot be placed on cut out squares. The cut out squares do not affect where the rooks can attack.
Based on the above data, answer the given subquestions.

What is the maximum number of edges that the graph constructed in the previous question can have?

  1. A

    R.C

  2. B

    R + C

  3. C

    R²

  4. D

    C²

Show answer

Correct answer

  • A

    R.C

Question 12

+3 marksOne correct option

Consider the following instance of Set Cover problem:

  • Universe U={a,b,c,d}\mathcal{U} = \{a, b, c, d\}
  • Family F={S1={a,c},S2={a,d},S3={b,d},S4={b,c}}\mathcal{F} = \left\{S_1 = \{a, c\}, S_2 = \{a, d\}, S_3 = \{b, d\}, S_4 = \{b, c\}\right\}

We use dynamic programming to find the minimum number of sets from F\mathcal{F} required to cover U\mathcal{U}. Recall that for every X⊆UX \subseteq \mathcal{U} and every 0≤j≤∣F∣0 \leq j \leq |\mathcal{F}|, our algorithm computes and stores Π(X,j)\Pi(X, j), i.e., minimum number of sets from Fj={S1,…,Sj}\mathcal{F}_j = \{S_1, \ldots, S_j\} required to cover XX.

Consider the following DP table:

{a,b,c,d}\{a, b, c, d\}∞\infty∞\infty∞\infty22
{b,c,d}\{b, c, d\}∞\infty∞\infty∞\infty22
{a,c,d}\{a, c, d\}∞\infty∞\infty222
{a,b,d}\{a, b, d\}∞\infty∞\infty∞\infty22
{a,b,c}\{a, b, c\}∞\infty∞\infty∞\infty22
{c,d}\{c, d\}∞\infty∞\infty222
{b,d}\{b, d\}∞\infty∞\infty∞\infty11
{b,c}\{b, c\}∞\infty∞\infty∞\infty21
{a,d}\{a, d\}∞\infty∞\infty111
{a,c}\{a, c\}∞\infty1111
{a,b}\{a, b\}∞\infty∞\infty∞\infty22
{d}\{d\}∞\infty∞\infty111
{c}\{c\}∞\infty1111
{b}\{b\}∞\infty∞\infty∞\infty11
{a}\{a\}∞\infty1111
Φ\Phi00000
XX / jj01234

Based on the above data, answer the given subquestions.

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

Correct answer

  • C

Question 13

+3 marksOne correct option

Consider the following instance of Set Cover problem:

  • Universe U={a,b,c,d}\mathcal{U} = \{a, b, c, d\}
  • Family F={S1={a,c},S2={a,d},S3={b,d},S4={b,c}}\mathcal{F} = \left\{S_1 = \{a, c\}, S_2 = \{a, d\}, S_3 = \{b, d\}, S_4 = \{b, c\}\right\}

We use dynamic programming to find the minimum number of sets from F\mathcal{F} required to cover U\mathcal{U}. Recall that for every X⊆UX \subseteq \mathcal{U} and every 0≤j≤∣F∣0 \leq j \leq |\mathcal{F}|, our algorithm computes and stores Π(X,j)\Pi(X, j), i.e., minimum number of sets from Fj={S1,…,Sj}\mathcal{F}_j = \{S_1, \ldots, S_j\} required to cover XX.

Consider the following DP table:

{a,b,c,d}\{a, b, c, d\}∞\infty∞\infty∞\infty22
{b,c,d}\{b, c, d\}∞\infty∞\infty∞\infty22
{a,c,d}\{a, c, d\}∞\infty∞\infty222
{a,b,d}\{a, b, d\}∞\infty∞\infty∞\infty22
{a,b,c}\{a, b, c\}∞\infty∞\infty∞\infty22
{c,d}\{c, d\}∞\infty∞\infty222
{b,d}\{b, d\}∞\infty∞\infty∞\infty11
{b,c}\{b, c\}∞\infty∞\infty∞\infty21
{a,d}\{a, d\}∞\infty∞\infty111
{a,c}\{a, c\}∞\infty1111
{a,b}\{a, b\}∞\infty∞\infty∞\infty22
{d}\{d\}∞\infty∞\infty111
{c}\{c\}∞\infty1111
{b}\{b\}∞\infty∞\infty∞\infty11
{a}\{a\}∞\infty1111
Φ\Phi00000
XX / jj01234

Based on the above data, answer the given subquestions.

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

Correct answer

  • A

Question 14

+1 markNumerical answer

The three-bonaci numbers are defined as follows (please read the definition carefully, as it may not be the generalization of the popular Fibonacci numbers that you might expect):

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 8

Question 15

+1 markNumerical answer

The three-bonaci numbers are defined as follows (please read the definition carefully, as it may not be the generalization of the popular Fibonacci numbers that you might expect):

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 20

Question 16

+1 markNumerical answer

The three-bonaci numbers are defined as follows (please read the definition carefully, as it may not be the generalization of the popular Fibonacci numbers that you might expect):

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 666

Question 17

+3 marksOne correct option

In the MIN-2-SAT problem, we are given a 2-CNF formula ϕ\phi and an integer kk, and the objective is to decide whether there exists an assignment for ϕ\phi that satisfies at most kk clauses.

Consider the following branching algorithm for the problem.

If there is a variable xx that occurs only positively in ϕ\phi, observe that there exists an optimal assignment that sets it to 00. Similarly, if there is a variable xx that occurs only positively in ϕ\phi, there exists an optimal assignment that sets it to 11. Once we perform this preprocessing, assuming that have clauses remaining, we have the following guarantee:

Every variable has at least one positive and one negated occurrence.

Now we can branch exhaustively on the settings of variables. The overall algorithm is summarized in the following pseudocode:

text
MINSAT(phi,k):
if there is a variable x that occurs only as a positive literal:
set x to 0
if there is a variable x that occurs only as a negated literal:
set x to 1
if phi is empty:
return YES
if phi is not empty and k <= 0:
return NO
Let x be any variable that occurs in phi.
return MINSAT(phi|[x = TRUE],k-1) OR MINSAT(phi|[x = FALSE],k-1)

Which of the following statements is true?

  1. A

    In both branches of the algorithm, at least one clause is falsified.

  2. B

    In both branches of the algorithm, at least one clause is satisfied.

  3. C

    In both branches of the algorithm, at least two clauses are falsified.

  4. D

    In both branches of the algorithm, at least two clauses are satisfied.

Show answer

Correct answer

  • B

    In both branches of the algorithm, at least one clause is satisfied.

Question 18

+2 marksOne correct option

Consider the given statements and answer if they are true or false.

The worst-case running time and expected running time are equal to within constant factors for any randomized algorithm.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 19

+2 marksOne correct option

Consider the given statements and answer if they are true or false.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 20

+2 marksOne correct option

Answer the given subquestions.

Every linear program has a unique optimal solution.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 21

+2 marksOne correct option

Answer the given subquestions.

Recall that in the vertex cover problem, we are trying to find a smallest subset SS of vertices in a graph GG such that G∖SG \setminus S is an independent set; in other words, for every edges (u,v)(u, v) in the graph GG, we have that {u,v}∩S\{u, v\} \cap S is non-empty.

Consider the algorithm that repeats the following steps as long as the graph has at least one edge available: select a vertex of maximum degree (say ww), and include ww in the solution; thereafter, delete ww and all edges incident to ww.

Is it true that the algorithm always outputs a vertex cover?

  1. A

    Yes

  2. B

    No

Show answer

Correct answer

  • A

    Yes

Question 22

+2 marksOne correct option

Answer the given subquestions.

Consider the algorithm in the previous question. Does the algorithm always output an optimal vertex cover?

  1. A

    Yes

  2. B

    No

Show answer

Correct answer

  • B

    No

Question 23

+2 marksOne correct option

Answer the given subquestions.

Consider the algorithm in the previous question no 22. Does the algorithm always output a 2- approximate vertex cover?

  1. A

    Yes

  2. B

    No

Show answer

Correct answer

  • B

    No

Question 24

+2 marksOne correct option

Answer the given subquestions.

Recall that the size of an optimal vertex cover is at most twice the size of a maximum matching of a graph G. Are there examples of graphs where the size of the optimal vertex cover is exactly equal to twice the size of its maximum matching? For example, this is not true for a path on three vertices: the size of both the maximum matching and minimum vertex cover is 1.

  1. A

    Yes

  2. B

    No

Show answer

Correct answer

  • A

    Yes