In this problem, we say that a vector with n integer numbers v[0..n−1] is unimodal if n ≥ 1, and there exists an index j such that 0 ≤ j ≤ n−1 and satisfying:
For instance, the vector [0, 2, 5, 7, 6, 5, 4, 3, 1] is unimodal (with j = 3).
Note that vectors with n ≤ 2 different elements are unimodal. In general, note that any strictly increasing vector is also unimodal (and in all cases j = n−1), and analogously, any strictly decreasing vector is also unimodal (and then j = 0).
Implement an efficient function
such that, given an integer number x and a unimodal vector v, returns true if x appears in v, and false otherwise. You can use and implement auxiliary functions if you need them.
Precondition
The vector v is unimodal.
Observation You only need to submit the required procedure; your main program will be ignored.