Question

Let GG be an undirected graph, which is a path on 8 vertices. The number of matchings in GG is ______. (answer in integer)

Official answer and solution
Official answer
34
From
Official GATE 2026 answer key

Solution

Use the Fibonacci recurrence Mn=Mn−1+Mn−2M_n = M_{n-1} + M_{n-2} for the number of matchings (independent edge sets, including the empty set) in a path graph PnP_n on nn vertices.

Let MnM_n denote the number of matchings (subsets of pairwise non-adjacent edges, including the empty matching) in a path graph PnP_n on nn vertices. For the last edge e=(vn−1,vn)e = (v_{n-1}, v_n):

  • Matchings that do not include ee correspond to matchings of Pn−1P_{n-1} (Mn−1M_{n-1}).
  • Matchings that do include ee cannot use (vn−2,vn−1)(v_{n-2}, v_{n-1}) and correspond to matchings of Pn−2P_{n-2} (Mn−2M_{n-2}).

With base cases M1=1M_1 = 1 (empty matching) and M2=2M_2 = 2 (empty matching and the single edge):

M1=1,  M2=2,  M3=3,  M4=5,  M5=8,  M6=13,  M7=21,  M8=34M_1 = 1,\; M_2 = 2,\; M_3 = 3,\; M_4 = 5,\; M_5 = 8,\; M_6 = 13,\; M_7 = 21,\; M_8 = 34
Final answer

34

Common trap

Forgetting to count the empty matching ∅\emptyset (which would give 33).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
Question
57 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.