Question: write in c++ code using vectors ip search problem input: a vector V of n integers output: the position of the last dip in V,

write in c++ code using vectors
ip search problem input: a vector V of n integers output: the position of the last dip in V, or None if V does not contain a dip Here a dip is a sequence of three contiguous elements ",, -1. '-2 where , -2 and YY2 For example, the sequence 5, 2, 5 is a dip. The integers are not required to be positive, so -4,-6, -4 is also a dip Note that the problem definition asks for the last occurring dip. 0 1 algorithm must return the later one (i.e. the one at the higher index) 1 ans mult e a DS a co rec The following algorithm solves the dip search problem dip_search(V) last_dip -None for i from 0 through n-3: If VMVi+2] and Vi+ last_dip i return last _dip
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
