Must answer properly attach output screenshot What would be the CONCURRENT implementation of it. (identify which part(s) can be executed concurrently such that the overall result is correct but a faster execution is realized.) Totient ranges to be testes using concurrent implementation of the code: Sum of totients between 1 and 10000 Sum of totients between 1 and 20000 Sum of totients between 1 and 50000 what i understand so far: In order to implement this code in a concurrent manner, the sumTotient function would need to be segmented into many smaller parts that are capable of running in parallel with one another. For instance, the sumTotient method may be segmented into four distinct parts, with each part corresponding to a different set of numerical values (e.g. 1-2500, 2501-5000, 5001-7500, and 7501-10000). It would therefore be possible to process these four pieces simultaneously, which would result in a quicker overall execution time.   What would be the CODE for the concurrent implementation?     Using this code import java.lang.System; public class TotientRange{ long hcf(long x, long y){ long t; while (y != 0) { t = x % y; x = y; y = t; } return x; } boolean relprime(long x, long y){ return hcf(x, y) == 1; } long euler(long n){ long length, i; length = 0; for (i = 1; i <= n; i++) if (relprime(n, i)) length++; return length; } long sumTotient(long lower, long upper){ long sum, i; sum = 0; for (i = lower; i <= upper; i++) sum = sum + euler(i); return sum; } public static void main(String[] args){ long lower = 0; long upper = 0; try{ lower = Long.parseLong(args[0]); upper = Long.parseLong(args[1]); }catch(Exception e){ System.out.println("Error (lower: " + lower + ", upper: " + upper + ")"); return; } TotientRange tr = new TotientRange(); long startTime = System.nanoTime(); System.out.println("Totient Sum: " + tr.sumTotient(lower, upper)); long endTime = System.nanoTime(); long duration = ((endTime - startTime) / 1000000) / 1000; System.out.println("Time Taken: " + duration + " seconds"); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Topic Video
Question

Must answer properly attach output screenshot

What would be the CONCURRENT implementation of it. (identify which part(s) can be executed concurrently such that the overall result
is correct but a faster execution is realized.)

Totient ranges to be testes using concurrent implementation of the code:

Sum of totients between 1 and 10000
Sum of totients between 1 and 20000
Sum of totients between 1 and 50000

what i understand so far:

In order to implement this code in a concurrent manner, the sumTotient function would need to be segmented into many smaller parts that are capable of running in parallel with one another. For instance, the sumTotient method may be segmented into four distinct parts, with each part corresponding to a different set of numerical values (e.g. 1-2500, 2501-5000, 5001-7500, and 7501-10000). It would therefore be possible to process these four pieces simultaneously, which would result in a quicker overall execution time.

 

What would be the CODE for the concurrent implementation?

 

 

Using this code

import java.lang.System;

public class TotientRange{

long hcf(long x, long y){
long t;

while (y != 0) {
t = x % y;
x = y;
y = t;
}
return x;
}

boolean relprime(long x, long y){
return hcf(x, y) == 1;
}

long euler(long n){
long length, i;

length = 0;
for (i = 1; i <= n; i++)
if (relprime(n, i))
length++;
return length;
}

long sumTotient(long lower, long upper){
long sum, i;

sum = 0;
for (i = lower; i <= upper; i++)
sum = sum + euler(i);
return sum;
}

public static void main(String[] args){
long lower = 0;
long upper = 0;

try{
lower = Long.parseLong(args[0]);
upper = Long.parseLong(args[1]);
}catch(Exception e){
System.out.println("Error (lower: " + lower + ", upper: " + upper + ")");
return;
}

TotientRange tr = new TotientRange();

long startTime = System.nanoTime();
System.out.println("Totient Sum: " + tr.sumTotient(lower, upper));
long endTime = System.nanoTime();

long duration = ((endTime - startTime) / 1000000) / 1000;
System.out.println("Time Taken: " + duration + " seconds");
}
}

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY