Data Structures & AlgorithmsVery hardICPC regional · tree queries

Problem: What is the complexity of answering distance queries on a tree after O(n log n) preprocessing with the sparse-table LCA?

  1. A. O(1) per query
  2. B. O(log n) per query
  3. C. O(n) per query
  4. D. O(sqrt n) per query

Correct answer: A. O(1) per query

The Euler-tour sparse table answers LCA queries as a range minimum in O(1).

More Coding Interview Problems questions

Exams that ask this topic