A vector R is a vector that is composed of two parts:
such that the part and the part are ordered strictly in increasing order but . Furthermore, we have that . That is, neither part is empty.
We need to implement the function
void ordena(vector<int>& v, int pos) with the
following specification:
PRE:
is a vector R such that
,
and
is the position of
in
.
POST: The vector
is sorted.
You only need to send the function we ask for and the actions and functions that you define yourself. The rest will be ignored.
You cannot use the operation sort from the
stl library.
Hint: knowing the position of can help you sort the vector in linear time.
On the other hand, if you use an auxiliary vector to sort you will have a penalty of on manual correction even if you have a green traffic light.
An undetermined number of vectors R with the following format: an integer indicating their size, then the vector R and finally the position where is located. Every vector R has a size greater than or equal to 3.
The sorted vector .
ENTRADA 1: 15 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 5 SORTIDA 1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ENTRADA 2: 15 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 13 SORTIDA 2: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ENTRADA 3: 15 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 SORTIDA 3: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ENTRADA 4: 5 12 15 4 7 8 2 SORTIDA 4: 4 7 8 12 15