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 8508611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:12:33+00:00 2026-06-11T03:12:33+00:00

I have these two find algorithm which look the same to me. Can anyone

  • 0

I have these two find algorithm which look the same to me. Can anyone help me out why they are actually different?

Find ( x ) :
    if x.parent = x then 
        return x
    else 
        return Find ( x.parent )

vs

Find ( x ) :
    if x.parent = x then 
        return x
    else 
        x.parent <- Find(x.parent)
        return x.parent 

I interpret the first one as

 int i = 0;    
 return i++;

while the second one as

int i = 0;
int tmp = i++;
return tmp

which are exactly the same to me.

  • 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-11T03:12:34+00:00Added an answer on June 11, 2026 at 3:12 am

    This looks like Disjoint-set data structure.

    Now to the question:

    For the sake of clarity first version is FindA, second is FindB.

    Suppose you have structure:

     0
     |
     1
     |
     2
     |
    ...
     n
    

    First call to FindA(n) will return 0 in O(n), second call will return 0 in O(n) and so on.

    If you call FindB(n) it will return 0 in O(n), but will also modify structure:

        0
     / /|\
    1 2...n 
    

    Now second call to FindB(n) will return 0 in O(1). More over FindB(k) will return 0 in O(1).

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

Sidebar

Related Questions

I have two vectors with different length in R and I can combine these
I have these two data structures that I continually find myself choosing between when
I am evaluating datamining packages. I have find these two so far: RapidMiner Weka
I want to find an algorithm which can find broken lines or shapes in
Does anyone have any good references for equations which can be implemented relatively easily
I'm looking for an algorithm which can take two sets of integers (both positive
I have two different algorithms and want to know which one performs better in
I have these two lines in my web.xml <url-pattern>/</url-pattern> : Index Servlet and <url-pattern>/login</url-pattern>
I have these two tables people ============ id, name and answer_sheets ============ id, person_id,
I have these two modules : package G1; sub new { my $class =

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.