Quiz Space

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

Question 1: In this problem you are given as input a graph T = (V, E)…

Question 1

+3 marksOne correct option

In this problem you are given as input a graph T=(V,E)T = (V, E) that is a tree (that is, TT is undirected, connected, and acyclic). A perfect matching of TT is a subset F⊂EF \subset E of edges such that every vertex v∈Vv \in V is the endpoint of exactly one edge of FF.

Equivalently, FF matches each vertex of TT with exactly one other vertex of TT. For example, a path graph has a perfect matching if and only if it has an even number of vertices.

Consider the following two algorithms that attempt to decide whether or not a given tree has a perfect matching. The degree of a vertex in a graph is the number of edges incident to it.

Algorithm A:

text
1 While T has at least one vertex:
2 If T has no edges:
3 halt and output ”T has no perfect matching.”
4 Else:
5 Let v be a vertex of T with maximum degree.
6 Choose an arbitrary edge e incident to v.
7 Delete e and its two endpoints from T.
8 (end of while loop]
9 Halt and output ”T has a perfect matching.”

Algorithm B:

text
1 While T has at least one vertex:
2 If T has no edges:
3 halt and output ”T has no perfect matching.”
4 Else:
5 Let v be a vertex of T with minimum non-zero degree.
6 Choose an arbitrary edge e incident to v.
7 Delete e and its two endpoints from T.
8 (end of while loop]
9 Halt and output ”T has a perfect matching.”

Is either algorithm correct?

Hint: Recall that every tree with at least two vertices has at least one degree one vertex.

  1. A

    Neither algorithm always correctly determines whether or not a given tree graph has a perfect matching.

  2. B

    Both algorithms always correctly determine whether or not a given tree graph has a perfect matching.

  3. C

    Algorithm B always correctly determines whether or not a given tree graph has a perfect matching; algorithm A does not.

  4. D

    Algorithm A always correctly determines whether or not a given tree graph has a perfect matching; algorithm B does not.

Show answer

Correct answer

  • C

    Algorithm B always correctly determines whether or not a given tree graph has a perfect matching; algorithm A does not.

Question 1 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 3 marks.

This question was also asked in

More questions from this paper

  1. Q2Consider the task of counting how many sequences of length n exist consisting only of numbers 0, 1, and 2 such that eac…
  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. Q8Figure question
  8. Q9Choose the correct options:
  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. Q14Consider the given statements and answer the subquestions if they are true or false. The worst-case running time and ex…
  14. Q15Consider the given statements and answer the subquestions if they are true or false. An adversary can provide randomize…
  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. Q18Recall that the size of an optimal vertex cover is at most twice the size of a maximum matching of a graph G. Are there…
  18. Q19Consider the following approximation algorithm for the weighted vertex cover problem. 1: Solve the relaxed linear progr…
  19. Q20Consider the following approximation algorithm for the weighted vertex cover problem. 1: Solve the relaxed linear progr…
  20. Q21Figure question