Question: Prepend Function of a Vector. Any language, any algorithm Vectors (or Dynamic Arrays) are sequence containers representing arrays that can change in size. Write the
Prepend Function of a Vector. Any language, any algorithm
Vectors (or Dynamic Arrays) are sequence containers representing arrays that can change in size. Write the prepend (add a new element to the beginning) function of a vector.
-- Example --
cout << vec << endl; // output: 3, 1, 4, 2, 8
vec.prepend(5);
cout << vec << endl; // output: 5, 3, 1, 4, 2, 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
