To solve the Subset Pair problem, we'll model it as a graph problem and show that it reduces to finding a Minimum Spanning Tree (MST) in an undirected graph. Here's the detailed algorithm, proof of correctness, and running time analysis.
Algorithm Design
Input:
- A set ( U = {a_1, a_2, \ldots, a_n} ).
- A family ( F ) of two-sized subsets of ( U ).
- A weight function ( w : F \rightarrow \mathbb{N} ).
Algorithm Steps:
-
Construct the Undirected Graph ( G ):
- The vertices of ( G ) are the elements of ( U ).
- The edges of ( G ) are the elements of ( F ).
- Each edge ( e \in F ) connects the two elements in the subset and has weight ( w(e) ).
-
Compute the Minimum Spanning Tree (MST) of ( G ):
- Use Kruskal's or Prim's algorithm to find the MST ( T ) of ( G ).
- MST ( T ) is a subset of edges ( S \subseteq F ) that connects all vertices in ( U ) with minimal total weight.
-
Output ( S ):
- Return ( S ) as the solution to the Subset Pair problem.
Proof of Correctness
We need to show that the subset ( S ) obtained from the MST satisfies conditions (a), (b), and (c) of the Subset Pair problem.
Condition (a): For every partition ( S = S_1 \sqcup S_2 ), there exists ( Y \in S_1 ) and ( Z \in S_2 ) such that ( Y \cap Z \neq \emptyset ).
Condition (b): ( \bigcup_{X \in S} X = U ).
Condition (c): ( S ) has minimal possible weight satisfying the above conditions.
Proof:
-
Condition (b) Holds:
- By definition of an MST, it spans all the vertices in ( U ), so all elements ( a_i ) are covered by the edges in ( S ). Hence, ( \bigcup_{X \in S} X = U ).
-
Condition (a) Holds:
- The MST ( T ) is a connected, acyclic graph (a tree).
- In the context of the Subset Pair problem, edges in ( S ) correspond to subsets in ( F ), and they are connected via shared vertices (elements of ( U )).
- For any partition ( S = S_1 \sqcup S_2 ) of the edges in ( T ), since ( T ) is connected, there must be some edge ( e_1 \in S_1 ) and ( e_2 \in S_2 ) that are connected through the tree.
- This implies there exists at least one vertex ( v \in U ) such that ( v \in e_1 \cap e_2 ).
- Therefore, ( Y = e_1 ) and ( Z = e_2 ) satisfy ( Y \cap Z \neq \emptyset ).
-
Condition (c) Holds:
- The MST has the minimal possible total weight among all connected graphs spanning ( U ).
- Any other subset ( S' \subseteq F ) satisfying conditions (a) and (b) must correspond to a connected subgraph covering all vertices.
- Since MST minimizes the total weight among all such connected subgraphs, ( S ) has minimal possible weight.
Running Time Analysis
Let ( n = |U| ) and ( m = |F| ).
-
Constructing the Graph ( G ):
- Time complexity: ( O(m) ).
- We simply use the given subsets ( F ) and their weights to build the graph.
-
Computing the MST:
-
Total Time Complexity:
- The dominant term is ( O(m \log m) ) (since ( m \geq n ) in a connected graph).
- The algorithm runs in polynomial time with respect to the size of ( F ) and ( U ).
Conclusion
By modeling the Subset Pair problem as an MST problem in graph theory, we can efficiently find the required subset ( S ) satisfying all conditions using well-known polynomial-time algorithms. The correctness is guaranteed by the properties of MSTs, and the running time is acceptable for practical purposes, scaling polynomially with the input size.
Final Answer: An algorithm that constructs a weighted graph from F and computes a Minimum Spanning Tree (MST) over U using the weights w; returning the MST's edges as S satisfies all conditions. Since MSTs can be found in polynomial time (using Kruskal's or Prim's algorithm), this algorithm solves the Subset Pair problem efficiently and correctly.