Skip to content
Official PYQ · 2018

GATE CS 2018 Q43 — Graph Traversals (BFS, DFS)

Explain with AI
Let GG be a graph with 100!100! vertices, with each vertex labelled by a distinct permutation of the numbers 1,2,…,100.1, 2,\ldots, 100. There is an edge between vertices uu and vv if and only if the label of uu can be obtained by swapping two adjacent numbers in the label of vv. Let yy denote the degree of a vertex in GG, and zz denote the number of connected components in GG. Then, y+10z=y+10z= ______.
View worked solution

Answer: 109

To find the value of y+10zy + 10z, we need to determine the degree of a vertex (yy) and the number of connected components (zz) in the graph GG.

1. Finding the Degree of a Vertex (yy)

Each vertex in GG represents a unique permutation of the numbers 1,2,…,1001, 2, \ldots, 100.

  • An edge exists between two vertices if one permutation can be obtained from the other by swapping exactly two adjacent elements.
  • For any permutation of length n=100n = 100, there are exactly n−1=99n - 1 = 99 adjacent pairs that can be swapped: (1,2),(2,3),…,(99,100)(1, 2), (2, 3), \ldots, (99, 100).
  • Swapping any of these adjacent pairs produces a unique, valid permutation.

Since the graph is undirected, the degree of every vertex is the same:

y=99y = 99

2. Finding the Number of Connected Components (zz)

A fundamental property of permutations is that any permutation can be transformed into any other permutation of the same set using a sequence of adjacent swaps (transpositions). This is the underlying principle of sorting algorithms like Bubble Sort.

  • Since we can transition from any vertex (permutation) to any other vertex via a sequence of adjacent swaps, there is a path between every pair of vertices in GG.
  • This means the graph GG is fully connected.

Thus, the number of connected components is:

z=1z = 1

3. Calculating y+10zy + 10z

Substituting the values of yy and zz:

y+10z=99+10(1)=109y + 10z = 99 + 10(1) = 109

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Graph Traversals (BFS, DFS) questions