Switch branches/tags
Find file
53b1fce Mar 8, 2015
@ekmett @sonyandy
50 lines (42 sloc) 2.13 KB
name: lca
category: Algorithms, Data Structures
version: 0.3
license: BSD3
cabal-version: >= 1.8
license-file: LICENSE
author: Edward A. Kmett
maintainer: Edward A. Kmett <>
stability: provisional
copyright: Copyright (C) 2011-2015 Edward A. Kmett
synopsis: O(log n) persistent on-line lowest common ancestor calculation without preprocessing
This package provides a reference implementation of my skew binary random access algorithm for performing an /online/ lowest common ancestor search (and online level ancestor search) in logarithmic time without preprocessing. This improves the previous known asymptotic bound for both of these problems from /O(h)/ to /O(log h)/, where /h/ is the height of the tree. Mostly importantly this bound is completely independent of the width or overall size of the tree, enabling you to calculate lowest common ancestors in a distributed fashion with good locality.
While /offline/ algorithms exist for both of these algorithms that that provide /O(1)/ query time, they all require at least /O(n)/ preprocessing, where /n/ is the size of the entire tree, and so are less suitable for LCA search in areas such as revision control where the tree is constantly updated, or distributed computing where the tree may be too large to fit in any one computer's memory.
Slides are available from
build-type: Simple
extra-source-files: .travis.yml HLint.hs
source-repository head
type: git
location: git://
hs-source-dirs: src
base >= 4 && < 5
ghc-options: -Wall -O2 -fspec-constr
test-suite doctests
type: exitcode-stdio-1.0
main-is: doctests.hs
ghc-options: -Wall -threaded
hs-source-dirs: tests
build-depends: base, doctest >= 0.8