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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:39:49+00:00 2026-05-18T06:39:49+00:00

Is there a built-in method in boost to find the lowest common ancestor of

  • 0

Is there a built-in method in boost to find the lowest common ancestor of two or more nodes in a tree (which is a boost::graph instance)?

If not, I would appreciate suggestions on the best way to do this. Wikipedia claims there are efficient algorithm to achieve this in O(1) time (with O(n) pre-processing), but it doesn’t describe the algorithms.

  • 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-05-18T06:39:49+00:00Added an answer on May 18, 2026 at 6:39 am

    Found the algorithm in Wikipedia:

     function TarjanOLCA(u)
     MakeSet(u);
     u.ancestor := u;
     for each v in u.children do
         TarjanOLCA(v);
         Union(u,v);
         Find(u).ancestor := u;
     u.colour := black;
     for each v such that {u,v} in P do
         if v.colour == black
             print "Tarjan's Least Common Ancestor of " + u +
                   " and " + v + " is " + Find(v).ancestor + ".";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any built-in method in OpenCV ( C++ API ) to subtract two
Is there any built in method to get which can parse int from string
Is there a pre-built method in EMFCompare that outputs the differences between two models
Is there any built in method that would combine the functions of Enumerable.select (find
Is there any built-in method in Java which allows us to convert comma separated
Here's a simple problem - given two urls, is there some built-in method, or
There is no built in reverse method for Python's str object. How can I
Is there a built-in data structure in Java to represent a Crit-bit tree? Or
Is there a built in method in Zend Framework to convert a REQUEST_URI to
Is there a built-in method to convert the .NET List<> into the F# list?

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.