Graph Theory37 sections · 1633 units
Open in Course

Section Recap

(What you learned)

You learned binary lifting, a technique that answers kk-th ancestor queries in O(logk)O(\log k) time after O(nlogn)O(n \log n) preprocessing. You built the sparse table up[v][j] (the 2j2^j-th ancestor of vv) using the recurrence up[v][j] = up[up[v][j-1]][j-1]. You answered queries by decomposing kk into powers of 22.

You solved three problems: Company Queries I (basic ancestor queries), Company Queries II (LCA with binary lifting), and Kth Ancestor of a Tree Node (LeetCode class-based version). You are now ready for more advanced tree techniques.