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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started