Question: 1. This function returns the number of sets in the DisjointSet. Note that this is not the same as the number of elements. You
1. This function returns the number of sets in the DisjointSet. Note that this is not the same as the number of elements. You can start with 2 elements in unique sets and join them using the union_set() function. def get_num_sets(self) 2.This function returns the size of the set containing element. If element does not exist within the disjoint set, function returns 0 def get_set_size(self, element): 3. Function performs a union of the two sets containing element1 and element2 respectively. If the two elements are already in the same set or if either of the elements do not exist, function does nothing and returns false, otherwise perform a union on the two sets, creating one set and return true def union_set(self, elementi, element2)
Step by Step Solution
3.62 Rating (163 Votes )
There are 3 Steps involved in it
1 def getnumsetsself return selfnumsets 2 def getsetsizeself element if element not in selfse... View full answer
Get step-by-step solutions from verified subject matter experts
