 Without preprocessing you can also improve the naïve online algorithm's computation time to O(log "h") by storing the paths through the tree using skew-binary random access lists, while still permitting the tree to be extended in constant time (Edward Kmett (2012)).This allows LCA queries to be carried out in logarithmic time in the height of the tree.While originally studied in the context of trees, the notion of lowest common ancestors can be defined for directed acyclic graphs (DAGs), using either of two possible definitions.