GATE / CS ARCHIVE

GATE CSE 2023 / QUESTION 56

GATE CSE 2023 Q56

Algorithms · Graph Algorithms · Full GATE CSE 2023 paper

GATE 2023, Q56 2 marks · NAT
Report issue

Graph Algorithms

Question 56, GATE 2023: The vertices of a graph are all eight subsets of {1,2,3}. Distinct vertices are adjacent exactly when one set is a subset of the other. How many different BFS vertex-visit orders can start at ∅, allowing arbitrary neighbor ordering?
Tap to enlarge
Answer & solution

Official answer: 5040

The empty set is a proper subset of every nonempty subset, so it is adjacent to each of the other seven vertices. BFS discovers all seven while scanning the start vertex. Any permutation of those neighbors can be its adjacency order; all seven are already discovered before any is expanded. Thus precisely 7!=5040 visit orders are possible.

Teaching detail. BFS uses a queue and discovers every neighbor of the start before expanding any of those neighbors. Since ∅ is contained in every subset, all other vertices are at distance one. No deeper layer imposes additional order constraints. Choosing any desired permutation of the seven neighbors as the start's adjacency-list order produces exactly that traversal after the fixed initial ∅. Thus the number is 7!, not 8!; the start position is not free. Later edges cannot create new vertices because all seven are already discovered.

Original paper, page 59 · Answer key