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?
- A. O(1)
- B. O(n)
- C. O(sqrt n)
- 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
- Problem: Which statement about building a binary heap from n given elements is correct?
- Problem: Which requirement must be met before the convex hull trick can answer queries in O(1) amortised time per query with a deque?
- Problem: Johnson's algorithm reweights edges with potentials before running Dijkstra. What does the reweighting achieve?
- Problem: Range-add updates and point queries on an array can be done with a Fenwick tree over which representation?
- Problem: What is the expected time of Rabin-Karp string matching with a good polynomial hash?
- Problem: How many pairs (i < j) of the array 1..14 have a[i] + a[j] divisible by 7? Run the code. python a = list(range(1, 15))…