Suppose we have a set of n disjoint nodes {node 1 , node 1 , ..., node nsub>}
What is the fastest data structure and algorithm for the following three operations:
Union (x, y): add an undirected edge between node x and node y , there can be at most one edge between two nodes.
IsConnected (x, y): returns true if node x and node y are connected directly or indirectly, i.e. node x and node y are in the same connection component.
Un-union (x, y): remove the border between node x and node y , if it exists.
Disjoint-set is an ideal data structure for the first two operations, but it cannot support the third operation directly. Which alternative?
If we simulate a process, the first and third operations can be implemented in O (1), but the 2nd operation is O (n), so I would like to see if all three operations can be done in O (logn) time or less.
outlaw
source share