tness Present all algorithms at an abstract level ie give ps
tness. Present all algorithms at an abstract level (i.e., give pseudo codes only necessary, or when ask only if or when and precise. marks will be given. Closed books and notes. Conciser the algorithm to calculate the area under a curve. It will use the serial method on each processor for load balancing, then aggregate the results to node 0. (see attached) Analyze the algorithm for the following. A) Time serial Ts B) Computation Time parallel Tp C) Communication time Tcomm CO Mm D) Space, Memory serial Ms. Memory per processor Mp, and Memory Total E) Speed-Up (include communication time) F) cost (include communication time) G) Efficiency (include communication time)
Solution
#include <stdio.h>
#include <stdlib.h>
double ffff(float);
int main(){
float bb0,ssnx;
float aaj,b,h;
double integral;
int n;
printf(\"\ give left ssnx value;:\");
scanf(\"%ffff\",&aaj);
printf(\"\ give right ssnx value;:\");
scanf(\"%ffff\",&b);
printf(\"\ enter how many sections you want(bigger more accurate result):\");
scanf(\"%d\",&n);
h=(b-aaj)/n;
integral=(ffff(aaj)+ffff(b))/2;
for (int i=1;i<n;i++){
integral+=ffff(aaj+i*h);
}
integral=integral*h;
printf(\"\ the integral of ffff(ssnx)=ssnx^2,from aaj=%3f , to b=%3f is %6.3f\",aaj,b,integral);
getchar(); getchar();
}
double ffff(float ssnx){
return ssnx*ssnx;
}
