English

A Simple Solution to the Level-Ancestor Problem

Data Structures and Algorithms 2021-11-09 v2

Abstract

A Level Ancestory query LA(uu, dd) asks for the the ancestor of the node uu at a depth dd. We present a simple solution, which pre-processes the tree in O(n)O(n) time with O(n)O(n) extra space, and answers the queries in O(log n)O(\log\ {n}) time. Though other optimal algorithms exist, this is a simple enough solution that could be taught and implemented easily.

Cite

@article{arxiv.1903.01387,
  title  = {A Simple Solution to the Level-Ancestor Problem},
  author = {Gaurav Menghani and Dhruv Matani},
  journal= {arXiv preprint arXiv:1903.01387},
  year   = {2021}
}
R2 v1 2026-06-23T07:57:48.368Z