---
title: "K-means on six 2-D instances (B65)"
subject: "Data Mining"
chapter: 5
key: "semester_7/data_mining:kmeans-b65"
source: https://www.bctengineer.com/q/semester_7/data_mining/kmeans-b65
site: BCT Engineering
---

# K-means on six 2-D instances (B65)

Data Mining · Chapter 5: Cluster Analysis

- Asked in: 2065 Baisakh
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/kmeans-b65
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-5

## Question

Cluster the following instances of given data (2-Dimensional form) with the help of K-means algorithm (Take K = 2).

| Instances | X | Y |
| --- | --- | --- |
| 1 | 1.0 | 2.5 |
| 2 | 1.0 | 4.5 |
| 3 | 2.5 | 3.0 |
| 4 | 2.0 | 1.5 |
| 5 | 4.5 | 1.5 |
| 6 | 4.0 | 5.0 |

## Short answer

Using Euclidean distance and initial centroids (1,2.5) and (1,4.5), K-means converges in two iterations. Clusters: {1,3,4,5} centroid (2.5,2.125); {2,6} centroid (2.5,4.75).

## Answer

**Assumption**: K = 2 and the initial centroids are instances 1 and 2: C1 = (1.0, 2.5), C2 = (1.0, 4.5). Distance d = √[(x − cx)² + (y − cy)²].

```text
1. Choose k and select k initial centroids (random objects).
2. Repeat
   a. Assign each object to the nearest centroid
      (Euclidean distance) -> k clusters.
   b. Recompute each centroid as the mean of its cluster.
3. Until no object changes cluster (centroids stable).
```

**Iteration 1**
| Instance | (X, Y) | d to C1 (1.0, 2.5) | d to C2 (1.0, 4.5) | Cluster |
| --- | --- | --- | --- | --- |
| 1 | (1.0, 2.5) | 0.00 | 2.00 | C1 |
| 2 | (1.0, 4.5) | 2.00 | 0.00 | C2 |
| 3 | (2.5, 3.0) | 1.58 | 2.12 | C1 |
| 4 | (2.0, 1.5) | 1.41 | 3.16 | C1 |
| 5 | (4.5, 1.5) | 3.64 | 4.61 | C1 |
| 6 | (4.0, 5.0) | 3.91 | 3.04 | C2 |

Clusters: C1 = {1, 3, 4, 5}, C2 = {2, 6}.
New centroids:
- C1 = ((1.0 + 2.5 + 2.0 + 4.5)/4, (2.5 + 3.0 + 1.5 + 1.5)/4) = **(2.5, 2.125)**
- C2 = ((1.0 + 4.0)/2, (4.5 + 5.0)/2) = **(2.5, 4.75)**

**Iteration 2**
| Instance | d to C1 (2.5, 2.125) | d to C2 (2.5, 4.75) | Cluster |
| --- | --- | --- | --- |
| 1 | 1.55 | 2.70 | C1 |
| 2 | 2.81 | 1.52 | C2 |
| 3 | 0.88 | 1.75 | C1 |
| 4 | 0.80 | 3.29 | C1 |
| 5 | 2.10 | 3.82 | C1 |
| 6 | 3.24 | 1.52 | C2 |

No instance changes its cluster, so the algorithm stops.

**Answer: Cluster 1 = {instances 1, 3, 4, 5}, centroid (2.5, 2.125); Cluster 2 = {instances 2, 6}, centroid (2.5, 4.75).**

Note: K-means depends on the initial centroids. With instances 1 and 6 as the starting centroids the result is C1 = {1, 2, 3, 4} (centroid (1.63, 2.88)) and C2 = {5, 6} (centroid (4.25, 3.25)).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In K-means, how is each instance assigned to a cluster?
   A. To the nearest centroid by Euclidean distance
   B. To the cluster with the most points
   C. To the farthest centroid
   D. Randomly each iteration
   Answer: A. Assignment uses the minimum distance to the centroids. (Key point: Assignment step)

2. With initial centroids instances 1 and 2, iteration 1 gives which clusters?
   A. C1 = {1, 2}, C2 = {3, 4, 5, 6}
   B. C1 = {1, 3, 4, 5}, C2 = {2, 6}
   C. C1 = {1, 3}, C2 = {2, 4, 5, 6}
   D. C1 = {1}, C2 = {2, 3, 4, 5, 6}
   Answer: B. Distances in the table show 3, 4, 5 are closer to (1.0, 2.5). (Key point: Cluster result)

3. What is the new centroid of C1 = {1, 3, 4, 5}?
   A. (2.5, 4.75)
   B. (2.0, 2.5)
   C. (2.5, 2.125)
   D. (1.0, 2.5)
   Answer: C. Mean x = (1+2.5+2+4.5)/4 = 2.5; mean y = (2.5+3+1.5+1.5)/4 = 2.125. (Key point: New centroid)

4. When does K-means stop?
   A. After exactly two iterations
   B. When centroids equal the initial ones
   C. When the clusters are of equal size
   D. When no object changes cluster
   Answer: D. Iteration 2 keeps the same assignments, so it has converged. (Key point: Stopping)

## Related in Data Mining

- [K-means on six 2-D instances (K=2)](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Akmeans-x-y-k2) — Data Mining, chapter 5
- [Cluster analysis; K-means on height/width](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Akmeans-height-width) — Data Mining, chapter 5
- [Cluster analysis applications; K-means](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Acluster-application-kmeans) — Data Mining, chapter 5
- [K-means on 1-D data, K=2 and K=3](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Akmeans-1d-k2-k3) — Data Mining, chapter 5
- [Need of clustering; hierarchical vs partitioning; K-means](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Acluster-need-hier-vs-partition-kmeans) — Data Mining, chapter 5
- [K-means on eight points into 3 clusters](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Akmeans-eight-points-k3) — Data Mining, chapter 5

## Related in other subjects

- [Algorithm and flowchart help; Armstrong flowchart](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-flowchart-armstrong) — Computer Programming, chapter 2
