Skip to content
Official PYQ · 2023

GATE CS 2023 Q46 — Graph Traversals (BFS, DFS)

Explain with AI
Let U={1,2,3}U=\{1,2,3\}. Let 2U2^{U} denote the powerset of UU. Consider an undirected graph GG whose vertex set is 2U2^{U}. For any A,B∈2U,(A,B)A, B \in 2^{U},(A, B) is an edge in GG if and only if (i) A≠BA \neq B, and (ii) either A⊊BA \subsetneq B or B⊊AB \subsetneq A. For any vertex AA in GG, the set of all possible orderings in which the vertices of GG can be visited in a Breadth First Search (BFS)\text{(BFS)} starting from AA is denoted by B(A)\mathcal{B}(A).

If ∅\emptyset denotes the empty set, then the cardinality of B(∅)\mathcal{B}(\emptyset) is ______________.
View worked solution

Answer: 5040

To find the cardinality of B(∅)\mathcal{B}(\emptyset), we need to determine the number of valid Breadth-First Search (BFS) orderings of the graph G=(V,E)G = (V, E) starting from the vertex ∅\emptyset.

1. Structure of the Graph

The vertex set VV is the power set of U={1,2,3}U = \{1, 2, 3\}:

V=2U={∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}V = 2^U = \{\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\}\}

The total number of vertices is ∣V∣=23=8|V| = 2^3 = 8.

An edge exists between two distinct vertices AA and BB if and only if A⊊BA \subsetneq B or B⊊AB \subsetneq A.

2. Neighbors of the Start Vertex ∅\emptyset

For any non-empty set B∈2U∖{∅}B \in 2^U \setminus \{\emptyset\}, the empty set is a proper subset of BB (i.e., ∅⊊B\emptyset \subsetneq B).

Therefore, the vertex ∅\emptyset is adjacent to every other vertex in the graph. The degree of ∅\emptyset is:

deg(∅)=8−1=7\text{deg}(\emptyset) = 8 - 1 = 7

3. BFS Traversal from ∅\emptyset

In a BFS starting from ∅\emptyset:

  1. The start vertex ∅\emptyset is visited first (at level 0).
  2. All remaining 77 vertices are direct neighbors of ∅\emptyset and are at distance 11 (level 1).
  3. Since all vertices in the graph are at distance ≤1\le 1 from ∅\emptyset, the BFS will visit ∅\emptyset first, followed by all 77 neighbors in some permutation.

Since the neighbors of a vertex can be visited in any arbitrary order during BFS, any permutation of these 77 vertices yields a valid BFS ordering.

4. Calculation

The number of possible BFS orderings is the number of permutations of the 77 neighbor vertices:

7!=7×6×5×4×3×2×1=50407! = 7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1 = 5040

Thus, the cardinality of B(∅)\mathcal{B}(\emptyset) is 5040.

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

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