Input X = { x 1 , x 2 , , x n } //set of n data items.

K // Number of desired clusters

Output:

A set of K clusters, c k : The center of each cluster and

Steps:

Repeat

· Calculate the distance between each data point and cluster centers using:

d = ( x i c x ) 2 + ( y i c y ) 2 + ( z i c z ) 2

· Assign the data point to the cluster center whose distance from the cluster center is minimum of all the cluster centers.

· Recalculate the new cluster center using:

c k = 1 / | G k | x i G k x i

Until the centers don’t change.