Skip to content

Conversation

LucasGdosR
Copy link
Contributor

No description provided.

// Finds the root of the component to which an element is connected.
public int find(int p) {
// Create a resizing array to compress the path of all elements along the way.
List<Integer> compressionList = new ArrayList<>();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not rely on ArrayList, but rather another vector in the data structure. This ensures constant add time. Note that array list provides an amortized one.

@ppenna ppenna self-requested a review June 26, 2023 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants