Question: Please use C programming Sample Execution : Problem 2: Shuffle the list of ints entered by the user. Your program should Ask the user to

Please use C programming

Please use C programming Sample Execution : Problem 2: Shuffle the list

Sample Execution

of ints entered by the user. Your program should Ask the user:

Problem 2: Shuffle the list of ints entered by the user. Your program should Ask the user to specify the number of element swaps swapCount that will be executed to randomize the list of ints. Randomly swaps (the contents of) two nodes of the list swapCount times a) b) To obtain a random number in [O, count] (count is the length of the list) use the following function #include #include #includenath. h> #include int rand_gen(int count) double frac; 1 frac(double)rand )/((double)RAND_MAX+1); return floor(count frac); //random number in [0, count] Include the following in the main to randomize the seed for the random function. srand((int)time (NULL)): /1 need only be applied once srand(int) randomizes the seed of the random number generator. A different seed will produce a different sequence of random numbers time (NULL)obtains the current system time. Hence it changes at every execution. rand )generates a random number in the range 0 and RAND_MAX. RAND_MAX is a system-defined upper bound on the maximum number that can be produced by rand () . To swap the contents of two elements of the list write a function with this prototype void swap(node *pt, int i, int j); pt is a pointer to the head of the list i: the ith list element j: the jth list element

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!