Resistant dichotomic search

Write an efficient function

        bool resistant_search(double x, const vector<double>& v);

that tells if @x@ belongs to the vector @v@ or not.

Precondition

The vector @v@ is “almost sorted” in nondecreasing order, in the sense
that there may be at most a pair of indices i and j such that
0 ≤ i < j < n and @V@[i] > @V@[j].

Observation

You only need to submit the required procedure; your main program will
be ignored.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:17:58.246Z

© Jutge.org, 2006–2026.
https://jutge.org
