Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise Objectives Applying random number generation Passing 1-D arrays to functions Call by reference Problem Description Write and run a C program with the following

image text in transcribed

Exercise Objectives Applying random number generation Passing 1-D arrays to functions Call by reference Problem Description Write and run a C program with the following functions Define and implement a function named printArray that receives two parameters: an array a of integers and its size n. The function should prints the contents of the array Define and implement a function named randomFillArray that receives two parameters: an array a of integers and its size n. The function should fill the array with n random integer values in the range -43 to 57 (inclusive) Define and implement a function named sortArray that receives two parameters: an array a of integers and its size n. The function should sort the array Define and implement a function named shuffleArray that takes two parameters: an array a and its size n. The function should do the following: 1) Generate a random number that represents an index x in the array, and generate another random number that represents an index y in the array. 2) Swap the array element at index x with the array element at index y. 3) If x = y no swap should occur. 4) The function should repeat steps 1, 2, and 3 n times. 5) The function should find and returns the number of swaps that have been done. Define and implement a function named mergeTwoLists that takes five parameters: three floating point arrays a, b and c, the size of sizes for array and the size of the second array. The function erges the two sorted lists a and b into a new sorted list c. This can be done using sizel + size2 comparisons where size and size2 are the sizes for first and second lists respectively. Implement a main function that performs the following: Defines three integer arrays at of size 10, a2 of size 20 and a3 of size 30. Uses function randomFillArray defined above to randomly intlize the array al. Uses function printArray to print the array a 1 after intlization Uses function randomFillArray defined above to randomly intlize the array a2. Uses function printArray to print the array a2 after intlization Uses function shuffleArray to shuffle the values in al. Uses function printArray to print the array a1 after shuffling Print the number of swaps performed in the function shuffleArray Uses function sortArray to sort the values in al. Uses function sortArray to sort the values in a2. Uses function merge TwoLists to merge the content of al and a2 and store the merged list in a 3 Uses function printArray to print the array a3 after shuffling 0 0 0 0 0 0 0 0

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

Understanding Groups

Answered: 1 week ago