Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:33:31+00:00 2026-06-03T21:33:31+00:00

FIND-SET(x) – returns the representative or a pointer to the representative of the set

  • 0

FIND-SET(x) – returns the representative or a pointer to the representative of the set that contains element x.

In algorithms find-set(x) is used in disjoint data structures. I don’t understand the use of this function. Suppose I have a graph with 4 vertices, a,b,c,d and the weights given as a-b=4, b-c=5, c-d=6 … How does find-set(u)!=find-set(v) (where u,v are any vertices of the graph) help me define the occurrence of a cycle in the graph!?? Find is defined as:

function Find(x)
     if x.parent == x
        return x
     else
        return Find(x.parent)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:33:33+00:00Added an answer on June 3, 2026 at 9:33 pm

    Find-Set(x) is used in disjoint data structures most frequently to implement Minimum Spanning Trees (MST).

    If u and v are in the same set, it means that they are already connected. If they are already connected, then adding another connection between them creates a cycle.

    We can begin analyzing this by saying that all vertices are within their own distinct, single-element sets. When we establish a connection between two vertices e.g. a-b, then we put a and b within the same set. Consequently, we need to determine how they’re in the same set; thus, we use Find-Set(x) to determine if they are within the same set (in your case, it’s a disjoint forest implementation).

    The example you provide does not have a cycle, so I’ll add another edge:

    Example

    Initially, assume we have a set of vertices a, b, c and d. We want to determine the minimum spanning tree such that there is the minimum number of edges possible to connect all three vertices to the same forest.

    Edges available now:
    (a, b), (c, d), (b, c), (d, c) (extra edge which is a cycle!)

    This assumes you know the definitions of vertex, edge and forest which are all fundamental graph terms

    Since a and b are currently distinct sets, we can combine them through an algorithm such as Merge-Set(a, b) which places them within the same set: A=(a, b) while there are still c and d that must be connected. Note here that A is the name of the set

    We can see that (c, d) is also possible; so, we can merge them: B=(c, d) and we also have (a, b). B is the name of this disjoint set

    Now we can merge A=(a, b) and B=(c, d) by knowing that we have edge (b, c). Since there are multiple elements within the set, we first determine whether the edge is necessary through Find-Set(x). If Find-Set(b) == Find-Set(c) then we know we have a cycle i.e. if A == B. Fortunately, we do not since (b, c) does not occur within either set A=(a, b) or B=(c, d). Now we merge them as usual and arrive at our MST which is a set: A=(a, b, c, d) (note that B has been deleted!).

    Recall our extra edge which is to be a cycle now. If we attempt to add (d, c), we see that the set which d and c reside in are the same i.e. Find-Set(d) == Find-Set(c) or A == A since d and c are both in set A. Consequently, we can determine that this edge creates a cycle!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What exactly find method of the standart set returns? Iterator to the actual element
I'm trying to write an algorithm that will find the set of all vertices
I find myself writing code that looks like this a lot: set<int> affected_items; while
Suppose I have an operation that receives a parameter java Set and returns Set.
I have a function that returns a pointer: static void *find_fit(size_t asize); I would
According to the HashSet javadoc, HashSet.contains only returns a boolean. How can I find
So I have a query set that returns a list of financial institutions and
I have the following query that returns a set of rows based on some
So I'm trying to find a way to return a very large result set
I'm a bit confused about using STL set::find() for a set of my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.