LCA and Binary Lifting
Find the lowest common ancestor, distances and k-th ancestors in a rooted tree by jumping 2^k steps at a time.
The problem
You have a rooted tree with n nodes. Each query gives two nodes u and v. The lowest common ancestor (LCA) is the deepest node that is an ancestor of both. Related queries: the distance between u and v, and the k-th ancestor of a node.
1 of 9