0% completed
Example code in C# is not Cyclic Division
Aldemar Hernández
Jan 5, 2025
The Example Code for C# is making a block division instead a Cyclic Division. I debugged the code, made desktop testing and found that implementation in the example code is making a Block Division.
I modified the code with the following:
I deleted the lines:
int chunkSize = arr.Length / NUM_THREADS; int start = threadId * chunkSize; int end = (threadId == NUM_THREADS - 1) ? arr.Length : start + chunkSize;
I modified the statement:
for (int i = start; i < end; ++i)
And I changed it for:
for (int i = threadId; i < arr.Length; i = i + NUM_THREADS)
And with that modification the access to the indexes is cyclic.
I didn't test the code in Java, but I think the same thing is happening.
0
0
Comments
On this page
Overview
Multithreading in Linear Search
Step-by-step Algorithm
Algorithm Walkthrough