Equivalence Classes Flashcards
Minimum Spanning Trees is an application/manipulation of equivalence classes
Minimum Spanning Trees results from establishing relationships between specific elements in a set.
The equivalence classes are disjoint subsets
No element of S belongs to a difference equivalence class
An equivalence relation E() over a set S defines a system of equivalence
classes within S
The equivalence class of some element x of S is that set of all y in S such that E(x,y) is true: • Note that every equivalence class defined this way is a subset of S • The equivalence classes are disjoint subsets: no element of S is in two different equivalence classes • The equivalence classes are exhaustive: every element of S is in some equivalence class
Kruskal’s Alogrithm
- Create a set with independent vertices
- Each vertex is considered in its own equivalence class.
- The algorithm considers edges in order of increasing cost. For
each edge:
• It is accepted if the vertices it connects are not in the same equivalence class
• If it is accepted, the equivalence classes containing the vertices it connects are joined into one equivalence class - When |V|-1 edges have been accepted, the algorithm terminates.
- The edges that have been accepted are the edges of the minimum spanning tree
These equivalence-class computations can be done very efficiently using a “disjoint subset”, “union/find” structure
An abstract data type (ADT) designed for basic computations on equivalence classes is sometimes called a “disjoint subset” structure (since equivalence classes are disjoint subsets of their domain). It is sometimes also called a “union-find” structure because of the names of its principal operations.
Create(int N)
Find(int i)
Union (int m, int n)
Implementing Disjoint SubSet Structure using :
LinkedList , when union just move all the contents into one head node
- however, this is very slow/inefficient , a it results in O(N^2 + NM)
Improving efficiency comes from how unions are executed in which item to “move” in a list.
Trees are a better approach than Linked List.
If using TREES. Each tree is a subset and each node has at most 1 parent.
Find(int i): will go to the node and traverse up parent until it reaches null and then return the label to identify which subset it belongs to
Union (m,n) : will make one subset’s parent point to the parent of the others subset.
Flaws in Implementations of a Disjoint Subset
Due to union-in order or how the union is designed the resulting trees might turn into a linked list.
While union will be O(k), the find will possibly take O(n)