Let be a graph with vertices, with each vertex labelled by a distinct permutation of the numbers . There is an edge between vertices and if and only if the label of can be obtained by swapping two adjacent numbers in the label of . Let denote the degree of a vertex in , and denote the number of connected components in . Then, ______.
GATE 2018 CS Q.43: solution and answer
Answer and solution
ANSWER
Official answer: 109Source: Official answer key, GATE 2018 CS (IIT Guwahati)
Each vertex is a permutation of . Two vertices are joined exactly when one label comes from the other by swapping two adjacent numbers (two neighbouring positions).
Degree: a label has pairs of neighbouring positions , for . Swapping the entries in positions and always gives a different permutation, because the two numbers are distinct. Two different position pairs give different results, because they change different positions. So each vertex has exactly neighbours, and .
Components: any permutation can be sorted into by repeatedly swapping an adjacent out-of-order pair (bubble sort). Each such swap moves along an edge, and edges are undirected. So every vertex is joined by a path to the identity permutation.
Every vertex lies in the same component as the identity permutation, so is connected and .
Therefore .
KEY IDEA
The graph has one vertex per permutation of 100 numbers and joins two permutations that differ by one adjacent swap. Each vertex has one neighbour per neighbouring position pair, which gives 99. Adjacent swaps can sort any permutation (bubble sort), so the graph is connected.
WATCH OUT FOR
Using or as the degree. Only swaps of neighbouring positions count, so the degree is , not the number of all pairs of positions. Another slip is to think the graph splits by parity of permutation. An adjacent swap changes parity, so the edges join even and odd permutations, but the graph is still connected.
From the GATE 2018 CS paper. Every question of this paper · Download the full paper · All 14 Graph theory questions, with notes
More Graph theory questions
- GATE 2026 CS1 Q.47 · MSQ · 2 marksLet G(V,E) be a simple, undirected graph. A vertex cover of G is a subset V' V such that for every (u,v) E…
- GATE 2026 CS1 Q.57 · NAT · 2 marksLet G be an undirected graph, which is a path on 8 vertices. The number of matchings in G is.
- GATE 2024 CS1 Q.34 · NAT · 1 markThe number of spanning trees in a complete graph of 4 vertices labelled A, B, C, and D is_
- GATE 2024 CS1 Q.51 · MSQ · 2 marksThe chromatic number of a graph is the minimum number of colours used in a proper colouring of the graph.
