Question: Problem 3. Complete the following function that replaces each element of a vector V with two copies of the element: void duplicate (vector &V) vector

 Problem 3. Complete the following function that replaces each element of

Problem 3. Complete the following function that replaces each element of a vector V with two copies of the element: void duplicate (vector<__> &V) vector C = V; V.clear (); while (C.size) 0) V.push_back (C[___l); V.push_back (CI__]); C.erase (0); For instance, the following tests should pass: "cat", "bird"); vector V("dog", duplicate (V); test(v.size() == 6); test (V [0] "dog" ) ; test(V[1]dog"); test(V[2]cat"); test(V[3] -- "cat"); test(V[4] -- ''bird'' ); test(V[5] -- "bird'' ); Let n be the length of V. The running time of duplicate is: ?6(1) 6(n) ?6(?)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!