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 ii and jj such that 0i<j<n0 \le i < j < n and @V@[ii] >> @V@[jj].

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