Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

Sample Execution

image text in transcribed:

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

Students also viewed these Databases questions

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago