Quiz Space

Advanced Algorithms · End Term · 31 Aug 2025 · May 2025 term · Set QIA1

Question 2: Consider the task of counting how many sequences of lengt…

Question 2

+2 marksOne correct option

Consider the task of counting how many sequences of length nn exist consisting only of numbers 00, 11, and 22 such that each number occurs at least once. We will solve this by calculating the number of sequences which do not contain at least one of the numbers.

Let's denote by AiA_i (i=0,1,2)(i = 0, 1, 2) the set of sequences in which the digit ii does not occur. The formula of inclusion-exclusion on the number of "bad" sequences is given by:

∣A0∪A1∪A2∣=∣A0∣+∣A1∣+∣A2∣−∣A0∩A1∣−∣A0∩A2∣−∣A1∩A2∣+∣A0∩A1∩A2∣|A_0 \cup A_1 \cup A_2| = |A_0| + |A_1| + |A_2| - |A_0 \cap A_1| - |A_0 \cap A_2| - |A_1 \cap A_2| + |A_0 \cap A_1 \cap A_2|

Based on the above data, answer the given subquestions.

  1. A

    3ⁿ

  2. B

    2ⁿ

  3. C

    n³

  4. D

    n²

Show answer

Correct answer

  • B

    2ⁿ

Question 2 of 21 in the IIT Madras BS Advanced Algorithms (Advanced Algorithms) End Term paper sat on 31 Aug 2025, in the May 2025 term (IIT M IMPROVEMENT FN EXAM QIA1 31 Aug 2025). It carries 2 marks.

More questions from this paper

  1. Q1In this problem you are given as input a graph T = (V, E) that is a tree (that is, T is undirected, connected, and acyc…
  2. Q3Consider the task of counting how many sequences of length n exist consisting only of numbers 0, 1, and 2 such that eac…
  3. Q4Consider the task of counting how many sequences of length n exist consisting only of numbers 0, 1, and 2 such that eac…
  4. Q5Consider the task of counting how many sequences of length n exist consisting only of numbers 0, 1, and 2 such that eac…
  5. Q6Consider the task of counting how many sequences of length n exist consisting only of numbers 0, 1, and 2 such that eac…
  6. Q7Figure question
  7. Q8Choose the correct options:
  8. Q9Figure question
  9. Q10Consider the following instance of Set Cover problem: Universe \mathcal{U} = {a, b, c} Family \mathcal{F} = {S_1 = {a, …
  10. Q11Consider the following instance of Set Cover problem: Universe \mathcal{U} = {a, b, c, d} Family \mathcal{F} = \left{S_…
  11. Q12Consider the following instance of Set Cover problem: Universe \mathcal{U} = {a, b, c, d} Family \mathcal{F} = \left{S_…
  12. Q13In the MIN-2-SAT problem, we are given a 2-CNF formula \phi and an integer k, and the objective is to decide whether th…
  13. Q14The worst-case running time and expected running time are equal to within constant factors for any randomized algorithm.
  14. Q15An adversary can provide randomized quicksort with an input array of length n that forces the algorithm to run in \omeg…
  15. Q16Every linear program has a unique optimal solution.
  16. Q17Recall that in the vertex cover problem,we are trying to find a smallest subset S of vertices in a graph G such that G …
  17. Q18Consider the algorithm in the previous question no 18. Does the algorithm always output an optimal vertex cover?
  18. Q19Consider the algorithm in the previous question no 18. Does the algorithm always output a 2- approximate vertex cover?
  19. Q20Recall that the size of an optimal vertex cover is at most twice the size of a maximum matching of a graph G. Are there…
  20. Q21Figure question