Data Structures & AlgorithmsVery hardICPC regional · algorithm theory
Problem: Which requirement must be met before the convex hull trick can answer queries in O(1) amortised time per query with a deque?
- A. The lines must all pass through the origin
- B. All slopes must be positive integers
- C. Line slopes are added in monotone order and queries are monotone
- D. The queries must be sorted in decreasing order only
Correct answer: C. Line slopes are added in monotone order and queries are monotone
Monotone slopes let the hull be maintained by popping from one end, and monotone queries let a pointer move forward.
More Coding Interview Problems questions
- 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))…
- Problem: Which is the worst-case time complexity of the median-of-medians selection algorithm for finding the k-th smallest element of n…
- Problem: What is the worst-case number of comparisons to merge two sorted lists of lengths m and n?