Skip to content

Instantly share code, notes, and snippets.

View Sushant's full-sized avatar

Sushant Bhadkamkar Sushant

View GitHub Profile
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: