This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def union(parent,child): | |
"""Performs a union by attaching the root node of the smaller set to the | |
root node of the larger set""" | |
if parent.set_size < child.set_size: | |
child, parent = parent, child | |
parent_head = find(parent) | |
child_head = find(child) | |
if parent_head == child_head: |