Question: solve in c++ program please i need to copy it from you so please ( type it and put the solution here ) so i
Write a function called small() that takes three arguments: the location of the first element k, the dimension nDim of a vector v, and the vector v itself, the function returns the index of the smallest element in the given vector from the location k to location nDim Write a function called swap that takes two arguments and swap their values. Write a main) program that input the dimension nDim and the elements of the vector, sort the elements of the vector in ascending order, and output the sorted elements. One way to sort the elements of a vector (there are more efficient ways) is to do the following Step 1: use the function small() to find the smallest element (among: X, X2, ..., xn), and use the function swap() to exchange it with the first element of the vector Step 2: use the function small() to find the smallest element (among: X2, Xz, ..., xn), and use the function swap() to exchange it with the second element of the vector Step 3: use the function small() to find the smallest element (among: X3, Xa, ..., xn), and use the function swap() to exchange it with the thircd element of the vector Step n-1: use the function small() to find the smallest element (among: xn1, Xn), and use the function swap() to exchange it with the (n-1)th element of the vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
