Safe Haskell | None |
---|---|
Language | Haskell2010 |
Lowest common ancestor queries on a tree
Uses an Euler tour and a sparse table for range minimum queries, with an range size optimization from 2n to n, adapted from PyRival.
Sources:
- https://en.wikipedia.org/wiki/Lowest_common_ancestor
- Michael Bender and Martin Farach-Colton, "The LCA Problem Revisited", 2000 https://www.ics.uci.edu/~eppstein/261/BenFar-LCA-00.pdf
- https://github.com/cheran-senthil/PyRival/blob/master/pyrival/graphs/lca.py