algorithms for LCA