Answered step by step
Verified Expert Solution
Question
1 Approved Answer
continue until we have lists of size 1 in length. Then starting with sublists of length 1 , merge the two sublists into a single
continue until we have lists of size in length. Then starting with sublists of length
"merge" the two sublists into a single sorted list.
Mergesort m
var list left, right, result
if lengthm
return
else
var middle engthm
for each in up to middle
add to left
for each in m after middle
add to right
left Mergesort eft
right Mergesort right
result Mergeeft, right
return result
The merge step is carried out by the following code:
Mergeeft,right
var list result
while lengtheft and lengthright
if firstleft firstright
append firstleft to result
left resteft
else
append firstright to result
right rest right
if lengtheft
append restleft to result
if lengthright
append restright to result
return result
$ Assume that you have Y cores on a multicore processor to run
MergeSort. Assuming that is much smaller than length express the speedup
factor you might expect to obtain for values of and lengthm Plot these on a
graph.
$ Next, assume that is equal to length m How would this
affect your conclusions your previous answer? If you were tasked with obtaining
the best speedup factor possible ie strong scaling explain how you might
change this code to obtain it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started