Skip to main content

GATE CSE 2023Algorithms › Graph AlgorithmsVerified

GATE CSE 2023 PYQ: Let U = { 1 , 2 , 3 } U=\{1,2,3\} U = { 1 , 2 , 3 } . Let 2 U 2^{U} 2 U denote the powerset of U U U .…

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 ______________.

    Answer

    5040

    Approach

    The graph's vertices are all subsets of U. Since every nonempty subset A satisfies ∅ ⊊ A, the empty set is adjacent to all 7 other vertices. Thus in BFS from ∅, all 7 remaining vertices are discovered immediately and form the first level; any relative order among them is possible because they are all marked visited when enqueued. Therefore the number of valid BFS orderings is just the number of permutations of these 7 vertices.

    Because ∅ is adjacent to all 7 nonempty subsets and there are no other vertices, any permutation of the 7 nonempty vertices is a valid BFS order after starting at ∅. Thus |B(∅)| = 7! = 5040.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.