Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
bartleby

Concept explainers

Question
Book Icon
Chapter 27, Problem 1P

(a)

Program Plan Intro

To reword the parallel loop in SUM-ARRAYS utilizing nested within the manner of MAT-VEC-MAIN-LOOP.

(a)

Expert Solution
Check Mark

Explanation of Solution

The implementation of the parallel loop that contains a worth grain-size to be specified is as follows:

SUM − ARRAYS’ (A, B, C)

  n=A.length

Grain − Size =?// to be calculated

  r=ceil(n/grainsize)fork=0tor1spawnADDSUBARRAY(A,B,C,k*grainsize+1,min((k+1)*grainsize,n))

Sync

ADD − SUBARRAY (A, B, C, i, j)

  fork=itojC[k]=A[k]+B[k]

Observing the algorithm SUM-ARRAYS (A, B, C) the parallelism is O(n) since it’s work is nlgn and the therefore the span is lgn .

(b)

Program Plan Intro

To calculate the parallelism of the given implementation if we set grain-size=1.

(b)

Expert Solution
Check Mark

Explanation of Solution

It can be concluded that each call to ADDSUBARRAY will return a sum of pair of numbers if the grain size = 1.

SUM − ARRAYS’ (A, B, C)

  n=floor(A.length/2)ifn==0C[1]=A[1]+B[1]elsespawnSUMARRAYS(A[1..n],B[1..n],C[1..n])SUMARRAYS(A[n+1..A.length],B[n+1..A..length],C[n+1..A.length])

(c)

Program Plan Intro

To formulate the span of SUM-ARRAYS’ in terms of n and grain-size and derived the most effective value worth for grain-size to maximize parallelism.

(c)

Expert Solution
Check Mark

Explanation of Solution

Assume g be the grain-size. The runtime of the function is ng . The runtime of any spawned task is g. So, we'd like to attenuate

  ng+g .

To get this we will perform calculus and get a derivative, we have

  0=1ng2 .

To further solve this, we set g=n . This minimizes the amount and makes the span O(ng+g)=O(n) and hence resulting in parallelism of O(n) .

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Please show the code for the Tikz figure of the complex plane and the curve C. Also, mark all singularities of the integrand.
11. Go to the Webinars worksheet. DeShawn wants to determine the number of webinars the company can hold on Tuesdays and Thursdays to make the highest weekly profit without interfering with consultations, which are also scheduled for Tuesdays and Thursdays and use the same resources. Use Solver to find this information as follows: a. Use Total weekly profit as the objective cell in the Solver model, with the goal of determining the maximum value for that cell. b. Use the number of Tuesday and Thursday sessions for the five programs as the changing variable cells. c. Determine and enter the constraints based on the information provided in Table 3. d. Use Simplex LP as the solving method to find a global optimal solution. e. Save the Solver model below the Maximum weekly profit model label. f. Solve the model, keeping the Solver solution. Table 3: Solver Constraints Constraint Cell or Range Each webinar is scheduled at least once on Tuesday and once on Thursday B4:F5 Each Tuesday and…
Go to the Webinars DeShawn wants to determine the number of webinars the company can hold on Tuesdays and Thursdays to make the highest weekly profit without interfering with consultations, which are also scheduled for Tuesdays and Thursdays and use the same resources. Use Solver to find this information as follows: Use Total weekly profit as the objective cell in the Solver model, with the goal of determining the maximum value for that cell. Use the number of Tuesday and Thursday sessions for the five programs as the changing variable cells. Determine and enter the constraints based on the information provided in Table 3. Use Simplex LP as the solving method to find a global optimal solution. Save the Solver model below the Maximum weekly profit model label. Solve the model, keeping the Solver solution. Table 3: Solver Constraints   Constraint Cell or Range Each webinar is scheduled at least once on Tuesday and once on Thursday B4:F5 Each Tuesday and Thursday…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning