Question: Put the ten numbers 0,1,2,..., 9 into an array or vector in random order (random permutation of these numbers, for instance 4,2,0,9,6,5,7,1,3,8). Use two different
Put the ten numbers 0,1,2,..., 9 into an array or vector in random order (random permutation of these numbers, for instance 4,2,0,9,6,5,7,1,3,8). Use two different approaches to do that and estimate (informally) which one is possibly more efficient or can't 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 how many calls to "rand()" function.
Thank you!! :)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
