Data Structures & AlgorithmsHardICPC regional · algorithm theory

Problem: Binary lifting on a rooted tree with n nodes uses O(n log n) preprocessing. What is the time for one LCA query?

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

Correct answer: D. O(log n)

The two nodes are lifted by powers of two in O(log n) steps, which is the standard bound.

More Coding Interview Problems questions

Exams that ask this topic