Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main thread randomly generates an array of double values with a given size ( say , N = 1 0 0 0 ) , and

Main thread randomly generates an array of double values with a given size (say, N=1000), and divides it into two smaller arrays of equal size. It then passes each sub-array to sorting_avg thread (creates two copies of the same thread), and waits until these two sub-arrays are sorted and the average of the values in each array are computed. It then calls merging_avg thread by passing the already sorted two sub-arrays, and the averages of the first and second sub-arrays as parameters.
Sorting_avg thread sorts the given sub-array using insertion sort or selection sort (one is enough and you need to implement either one), and computes the average of the values in the given array. So this thread returns sorted sub-array and its average.
Merging_avg thread takes both sorted sub-arrays and the their averages as parameters. It then merges them into a single sorted array in a linear time (so don't call sorting function again! You can simply have a loop and take the smallest from the sorted arrays until they are all merged!), and simply find the overall average by taking the average of the given two averages (this will work because we assume both sub-arrays have the same size!).

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions