Verified interview challenge
Implement K-means centroid updates
Implement the assignment and centroid-update steps of K-means with deterministic edge-case behaviour.
Unlock with Full AccessThe challenge
The dataset, starting centroids and iteration count are supplied. Run the required rounds while keeping point assignment separate from updating the centroids for the next round. The full task defines how ties and empty clusters behave, so results must follow those rules consistently rather than depend on incidental iteration order.
What you'll practise
Iteration state
Use a consistent centroid snapshot for each assignment round.
Numerical behaviour
Preserve deterministic cluster selection and coordinate updates across edge cases.
# Your implementation goes here
# Run examples and inspect results
# Full starter code includedRun your code to see results.