jwalsh / jwalsh/hy-algorithms

Implement Union-Find (Disjoint Set) data structure

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
data-structure difficulty:medium graph
Dominant language
Hy
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Create an efficient implementation of the Union-Find (Disjoint Set) data structure:

## Core operations:
- MakeSet - Create a new set with a single element
- Find - Determine which set an element belongs to
- Union - Merge two sets

## Optimizations to implement:
- Path compression for Find operation
- Union by rank/size
- Path splitting
- Path halving

## Applications to demonstrate:
- Kruskal's algorithm for MST
- Cycle detection in undirected graphs
- Connected components in a graph
- Least common ancestor in trees
- Percolation problems

## Requirements:
- Provide detailed complexity analysis
- Include amortized analysis
- Create comprehensive test cases
- Document practical applications

This data structure is fundamental for efficient implementations of many graph algorithms and has applications in network connectivity problems.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.