Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Update the K- means pseudocode in C++ of the parallel algorithm -- so, loops, te

ID: 3742991 • Letter: U

Question

Update the K- means pseudocode in C++ of the parallel algorithm -- so, loops, termination conditions, functions/procedures/methods (objects or no objects). Explain what are your data structures.
Then Explain what you parallelized, and what decomposition(s) you used (task, data, both (and in what order).
ThenProvide an example -- Assume you have 4 cores and 4 threads per core. The K-Means Clustering Method Given k, the k-means algorithm is implemented in four steps: Partition objects into k nonempty subsets - Compute seed points as the centroids of the clusters of the current partitioning (the centroid is the center, i.e., mean point, of the cluster) Assign each object to the cluster with the nearest seed point Go back to Step 2, stop when the assignment does not change

Explanation / Answer

#include<iostream.h>
#include<conio.h>
void main()
{
int i1,i2,i3,t1,t2;

int k0[10];
int k1[10];
int k2[10];

cout<<" Enter 10 numbers: ";
for(i1=0;i1<10;i1++)
{
cin>>k0[i1];
}


//initial means
int m1;
int m2;

cout<<" Enter initial mean 1:";
cin>>m1;
cout<<" Enter initial mean 2:";
cin>>m2;

int om1,om2; //old means

do
{

//saving old means
om1=m1;
om2=m2;

//creating clusters
i1=i2=i3=0;
for(i1=0;i1<10;i1++)
{
//calculating distance to means
t1=k0[i1]-m1;
if(t1<0){t1=-t1;}

t2=k0[i1]-m2;
if(t2<0){t2=-t2;}

if(t1<t2)
{
//near to first mean
k1[i2]=k0[i1];
i2++;
}
else
{
//near to second mean
k2[i3]=k0[i1];
i3++;
}

}

t2=0;
//calculating new mean
for(t1=0;t1<i2;t1++)
{
t2=t2+k1[t1];
}
m1=t2/i2;

t2=0;
for(t1=0;t1<i3;t1++)
{
t2=t2+k2[t1];
}
m2=t2/i3;

//printing clusters
cout<<" Cluster 1:";
for(t1=0;t1<i2;t1++)
{
cout<<k1[t1]<<" ";
}
cout<<" m1="<<m1;

cout<<" Cluster 2:";
for(t1=0;t1<i3;t1++)
{
cout<<k2[t1]<<" ";
}
cout<<" m2="<<m2;

cout<<" ----";
}while(m1!=om1&&m2!=om2);

cout<<" Clusters created";

//ending
getch();
}

Please change your variable names accordingly

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote