Data Structures & AlgorithmsHardCodeforces Div2 D · ternary search

Problem: Which property must a function have for ternary search to find its maximum correctly?

  1. A. It must be periodic
  2. B. It must be linear
  3. C. It must be unimodal (strictly increasing then strictly decreasing)
  4. D. It must have integer outputs only

Correct answer: C. It must be unimodal (strictly increasing then strictly decreasing)

Unimodality ensures that comparing two interior points discards a third of the interval safely.

More Coding Interview Problems questions

Exams that ask this topic