Which three insertions properly complete the pseudo-code?

Given the incomplete pseudo-code for a fork/join framework applications:
<code>
submit (Data) {
if (Data.size < SMALL_ENOUGH) {
_________(Data); // line X
}
else {
List<Data> x = _________________(Data); // line Y
for(Data d: x
______________(d); // line Z
}
}
</code>

And give the missing methods:

Process, submit, and splitInHalf

Which three insertions properly complete the pseudo-code?

Given the incomplete pseudo-code for a fork/join framework applications:
<code>
submit (Data) {
if (Data.size < SMALL_ENOUGH) {
_________(Data); // line X
}
else {
List<Data> x = _________________(Data); // line Y
for(Data d: x
______________(d); // line Z
}
}
</code>

And give the missing methods:

Process, submit, and splitInHalf

Which three insertions properly complete the pseudo-code?

A.
Insert submit at line X

B.
Insert splitHalf at line X

C.
Insert process at line X

D.
Insert process at line Y

E.
Insert splitHalf at line Y

F.
Insert process at line Z

G.
Insert submit at line Z

Explanation:
C: If Data.Size is “small enough” then process it directly.
E: Else we split it in half.
G: We use a recursive submit (of the splitted Data).



Leave a Reply 1

Your email address will not be published. Required fields are marked *


APercova

APercova

If data size is less than a small threshold, it’s processed directly.
If data size is equal or bigger than the threshold, it’s first divided in small pieces that can be processed partially each one on a different thread, then processing small pieces is done by making a recursive calling to the “submit” method.

So C,E,G are the right answers.