--- id: bin-jump title: "Binary Jumping" author: Benjamin Qi description: Introduces the problems of finding level ancestors in a tree and computing the lowest common ancestors. frequency: 3 --- import { Problem } from "../models"; export const metadata = { problems: { sample: [ new Problem("CSES", "Company Queries I", "1687", "Easy", false, ["Binary Jumping"], ""), ], lca: [ new Problem("CSES", "Company Queries II", "1688", "Easy", false, ["LCA"], ""), ], general: [ new Problem("CSES", "Planets Queries I", "1750", "Easy", false, ["Binary Jumping"], ""), new Problem("CSES", "Distance Queries", "1135", "Easy", false, ["LCA"], ""), new Problem("Plat", "Max Flow", "576", "Easy", false, ["LCA"], ""), new Problem("CSA", "Root LCA Queries", "root-lca-queries", "Normal", false, ["LCA"], ""), new Problem("CSES", "Planets Queries II", "1160", "Normal", false, ["LCA"], ""), new Problem("Plat", "Disruption", "842", "Normal", false, ["LCA"], ""), new Problem("DMOJ", "Hot & Cold", "bts17p7", "Normal", false, ["LCA"], ""), new Problem("TOKI", "Functional Constraint", "https://tlx.toki.id/contests/troc-12-div-1/problems/D", "Hard", false, ["LCA"], ""), new Problem("TOKI", "Graph & Destination", "https://tlx.toki.id/contests/troc-13-div-1/problems/E", "Hard", false, ["LCA"], ""), new Problem("Plat", "Tree Boxes", "948", "Hard", false, ["LCA"], "interactive!!"), new Problem("Plat", "Newbarns", "817", "Hard", false, ["Diameter"], "Copy of CF Brain Network \"Hard\": https://codeforces.com/contest/690/problem/C3"), new Problem("Plat", "Gathering", "866", "Hard", false, ["LCA"], "interactive!!"), new Problem("Plat", "Exercise", "901", "Very Hard", false, ["LCA"], ""), ] } }; ## Binary Jumping ## Lowest Common Ancestor ### Tutorial - [CF: $O(\log N)$ queries and $O(N)$ memory](https://codeforces.com/blog/entry/74847) - [Wikipedia: $O(1)$ queries and $O(N)$ preprocessing time](https://en.wikipedia.org/wiki/Level_ancestor_problem#Ladder_algorithm) - though explanation is not the greatest ### Problems