6

I was having a look at this question and then reading about Tarjan's least common ancestors algorithm. I never came across any applications of LCA algorithms before.

Where are such LCA algorithms commonly used?

Community
  • 1
  • 1
Lazer
  • 79,569
  • 109
  • 264
  • 349
  • 1
    Spatial data structure trees in scientific computing, suffix trees for strings in computational biology, etc. Forgot the details, sorry, but it's definitely useful. – polygenelubricants Aug 22 '10 at 17:26

3 Answers3

6

In compilers, the LCA of two basic blocks is a place you can put a computation so it is available to both. This might be useful for eliminating common subexpressions, or inserting phi-node for SSA conversion. These algorithms are well evolved and highly optimized, though, so the LCA itself may be hard to see, e.g., SSA and PRE

Doug Currie
  • 38,699
  • 1
  • 88
  • 113
5

Don't know where it is used, but I have a couple ideas where it might get used:

  • computer graphics: often 3D sceneries get split into cubes which form a tree structure. If you have an object which is contained in two such cubes a LCA algorithm gives you the smallest containing larger cube.

  • analysis of gens in order to find the relationships between species and their lowest common ancestor

  • merge algorithms of version control systems

Jens Schauder
  • 65,795
  • 24
  • 148
  • 294
  • 1
    thanks! version control -> three way merge: http://en.wikipedia.org/wiki/Merge_(revision_control)#Three-way_merge – Lazer Aug 22 '10 at 17:39
  • It is also useful for certain kinds of string processing when looking for root words for different suffixes. – Arnold Spence Aug 22 '10 at 18:13
-1

I just wrote a blog post about how I had to implement my own algorithm for this problem (extended to a set of nodes with an arbitrary length) for a taxonomy tree in the context of metagenomics:

http://blog.bio4j.com/2012/02/finding-the-lowest-common-ancestor-of-a-set-of-ncbi-taxonomy-nodes-with-bio4j/

Cheers,

Pablo

ppareja
  • 660
  • 4
  • 15