Data Structures & AlgorithmsHardCodeforces Div2 D · ternary search
Problem: Which property must a function have for ternary search to find its maximum correctly?
- A. It must be periodic
- B. It must be linear
- C. It must be unimodal (strictly increasing then strictly decreasing)
- 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
- Problem: Dijkstra with a binary heap on a graph with E = 10^6 edges and V = 10^5 vertices runs in roughly how many elementary operations?
- Problem: Which statement about Hopcroft-Karp is correct?
- Problem: What does the Gale-Shapley algorithm guarantee for stable matching with n men and n women?
- Problem: How many states does a bitmask DP over subsets of n = 15 items have?
- Problem: Which statement about the Floyd-Warshall algorithm's memory usage for V vertices is correct?
- Problem: Which problem asks for the minimum number of edges to add to make a graph 2-edge-connected?