Completed 2D K-Means sequential algorithm.