Question: C++ PROGRAMING LANGUAGE Put the ten numbers 0, 1, 2, , 9 into an array or a vector in random order, i.e, a random permutation

C++ PROGRAMING LANGUAGE

Put the ten numbers 0, 1, 2, , 9 into an array or a vector in random order, i.e, a random permutation of these numbers, for instance, 4, 2, 0, 9, 6, 5, 7, 1, 3, 8, by using function rand()1 . Use two different algorithms to do that and estimate (informally) which one is possibly more efficient or cant tell. Print the list and calculate how many numbers in the list that are located at their original positions (unchanged positions). For example, in the above list, only 5 is located at its original position (index of 5). Also print out how many calls to rand() function.

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!