The k-means algorithm and its working