Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class ParaT 2 0 2 3 2 0 2 3 extends RecursiveTask { { int lo , , hi , , val; int [

public class ParaT20232023 extends RecursiveTask {{
int lo,, hi,, val;
int[][] arr;
static final int CUT=5=5;
ParaT2023(2023(int[][] a,, int l,, int h,, int v){){ lo==l; hi==h; arr==a; val==v;}}
protected Integer compute(){(){
if((((hi−-lo)<)< CUT){){
int ans =−1=-1;
for((int i=(=(lo+1)+1); i << hi; i++){++){
if (( arr[[i]==]==val)) ans==i;
}}
return ans;
}}
else {{
ParaT20232023 left == new ParaT2023(2023(arr,,lo,(,(hi++lo)/2,)/2,val));
ParaT20232023 right== new ParaT2023(2023(arr,(,(hi++lo)/2,)/2,hi,,val));
left.fork()();
int rightAns == right.compute()();
int leftAns == left.join()();
if ((rightAns>−1)>-1) return rightAns;
return leftAns;
}}}}
public static void main((String[][] args)) throws Exception {{
int [][] arr ={0,1,2,3,4,5,0,7,8,0,10,11,12,13,14,15,0,17,18,19,20}={0,1,2,3,4,5,0,7,8,0,10,11,12,13,14,15,0,17,18,19,20};
final ForkJoinPool fjPool == ForkJoinPool.commonPool()();
int ans == fjPool.invoke((new ParaT2023(2023(arr,0,,0,arr.length,0))0));
System.out.println((ans));
}}//}}// How would i determine the number of threads used to execute this code which is apparently 4,4, and how would i determine the output if it is 16.16.

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

Step 1 Determine the number of threads Explanation The number of threads used to execute this code i... 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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions