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?

  1. A. The lines must all pass through the origin
  2. B. All slopes must be positive integers
  3. C. Line slopes are added in monotone order and queries are monotone
  4. 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

Exams that ask this topic