Graph Theory37 sections · 1633 units
Open in Course

HLD vs LCA Binary Lifting

(Updates vs queries)

Binary lifting with sparse tables answers LCA and path queries in O(logn)O(\log n) per query after O(nlogn)O(n \log n) preprocessing.

But it does not support updates. HLD supports updates in O(logn)O(\log n) and queries in O(log2n)O(\log^2 n) after O(n)O(n) preprocessing. The extra log factor comes from segment tree operations. If you only have queries and no updates, binary lifting is faster. If you have updates, HLD is the standard choice. Choose based on whether the problem requires updates.

Space complexity is O(n)O(n) for the data structures used.