Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE IN C. 2. Develop a multithreaded program to sort an array of integers. DON'T do this until you've solved problem 1! Your program should

CODE IN C.
image text in transcribed
2. Develop a multithreaded program to sort an array of integers. DON'T do this until you've solved problem 1! Your program should run with 4 threads and use the algorithm discussed in class o Break the array into four equally sized partitions o Sort the partitions separately in different threads o Merge the results back together. This is a 2 step process where two threads merge the four partitions into two partitions and then with one thread merge the two partitions into one o Write a simple routine that checks the final array is in sorted order. If the array is sorted print "Sort complete." Otherwise print an error message .Each of the worker threads should use a bubble sort algorithm (intentionally slow, see the pseudo code below) .Use an array size of 64,000 elements that you randomly initialize using rand ) You may find it interesting to try different sized arrays and vary the number of threads. During development you'll want to use a small array, perhaps start with 2 threads, and printout your array results to confirm the sort and merge worked. The final version of your program should only print out the simple message generated by your simple checker . . Along with your code, turn in a comparison of how much time the multithread program takes versus running the same problem using a 1 threaded bubblesort algorithm. To determine how much time is required, you might use the unix time program (or "timer" from the first programming assignment) Simple bubble routine for (x-0;xarrayly+1]) temp arraylyl arrayly+1]-temp

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions