Back to problems

k-Means from scratch

Algorithm · ByteDance · Medium

You are given a collection of two‑dimensional data points and must partition them into exactly k clusters using the standard k‑Means algorithm with a fixed number of iterations. You will receive the initial centroid coordinates; the algorithm starts with the assignment step (no initial cluster labels are provided). Perform exactly the requested number of iterations, each consisting of: Assignment step – for every point, compute the squared Euclidean distance to each centroid…

Loading the rest of the question…