Sample questions
Question 1Easy
In k-means, what does k represent?
- The number of features
- The number of clusters
- The number of iterations
- The number of nearest neighbours
Answer: B. The number of clusters
Explanation
k is chosen in advance, e.g. using the elbow method or silhouette scores.
Step-by-step solution
- K-means partitions data into k groups.
- Each group has one centroid.
- So k is the number of clusters, chosen in advance.
Why the other options are wrong
- A. The number of features is the data's dimensionality.
- C. Iterations run until convergence and are not k.
- D. Nearest neighbours is the k in kNN, a different algorithm.
Tip: k-means: k clusters. kNN: k neighbours.
Question 2Medium
What is the "elbow method" used for in k-means?
- Choosing k by plotting within-cluster error against k
- Initialising the centroids at points that are as far apart as possible
- Measuring cluster purity against labels
- Detecting outliers in a cluster
Answer: A. Choosing k by plotting within-cluster error against k
Explanation
Inertia always decreases as k grows; the bend (elbow) where improvement slows suggests a reasonable k.
Step-by-step solution
- Run k-means for k = 1, 2, 3, ...
- Plot within-cluster sum of squares (inertia) against k.
- Choose the k where the curve bends and gains flatten: the elbow.
Why the other options are wrong
- B. Spreading the initial centroids apart is k-means++ initialisation.
- C. Purity needs true labels; the elbow method uses none.
- D. The elbow method chooses k, it does not find outliers.
Question 3Medium
What does a dendrogram show in hierarchical clustering?
- The ROC curve of the clustering
- The training loss after each epoch of the clustering algorithm
- The order and distance at which clusters are merged (or split)
- The centroid of each cluster
Answer: C. The order and distance at which clusters are merged (or split)
Explanation
Cutting the dendrogram at a chosen height gives a particular number of clusters.
Step-by-step solution
- Hierarchical clustering merges (or splits) clusters step by step.
- A dendrogram is a tree diagram of those merges.
- Branch height shows the distance at which clusters joined; cutting it at a height gives clusters.
Why the other options are wrong
- A. ROC curves evaluate classifiers, not clusterings.
- B. Hierarchical clustering has no epochs or training loss.
- D. Centroids belong to k-means, not the dendrogram.
Question 4Medium
Which clustering algorithm can find arbitrarily shaped clusters and mark outliers as noise, without specifying the number of clusters?
- DBSCAN
- Gaussian mixture with 2 components
- K-medoids
- K-means
Answer: A. DBSCAN
Explanation
DBSCAN groups points in dense regions (eps, min_samples). K-means assumes roughly spherical clusters and needs k.
Step-by-step solution
- DBSCAN grows clusters from dense regions (points with enough neighbours within eps).
- Clusters can take any shape because they follow density.
- Points in sparse regions are labelled noise, and k is never specified.
Why the other options are wrong
- B. A Gaussian mixture with 2 components fixes the cluster count and assumes elliptical shapes.
- C. K-medoids needs k and favours compact, round clusters.
- D. K-means needs k and assumes roughly spherical clusters.
Tip: Odd shapes + outliers + unknown k -> DBSCAN.
Question 5Medium
K-means with k = 2 is run on 1-D points 1, 2, 4, 5, 9 with initial centroids 1 and 5. After the first assignment and update step, what are the new centroids?
- 1.5 and 6
- 2.33 and 7
- 2 and 6
- 1 and 5
Answer: A. 1.5 and 6
Explanation
Assign each point to the nearer centroid:
- 1, 2 -> centroid 1 (4 is nearer to 5);
- 4, 5, 9 -> centroid 5.
New centroids are the means:
(1 + 2)/2 = 1.5 and (4 + 5 + 9)/3 = 6.
Step-by-step solution
- Assign each point to the nearer centroid (1 or 5).
- 1, 2 go to centroid 1; 4, 5, 9 go to centroid 5 (4 is 3 from 1 but 1 from 5).
- New centroids: (1 + 2) / 2 = 1.5 and (4 + 5 + 9) / 3 = 6.
Why the other options are wrong
- B. 2.33 and 7 wrongly puts 4 in the first cluster.
- C. 2 and 6 miscomputes the mean of 1 and 2.
- D. These are the starting centroids; the update moves them.
Question 6Hard
Why is k-means sensitive to the initial choice of centroids?
- The number of clusters changes during training
- It always converges to the global minimum, so the start point affects only the speed
- It converges to a local minimum that depends on the start
- It does not use the centroids after initialisation
Answer: C. It converges to a local minimum that depends on the start
Explanation
Different initialisations can give different final clusters. k-means++ initialisation and multiple restarts (n_init) mitigate this.
Step-by-step solution
- K-means minimises within-cluster distance by local improvement steps.
- It stops at the first point where no step helps: a local minimum.
- Different starting centroids can lead to different final clusters.
Why the other options are wrong
- A. k is fixed during training.
- B. K-means is not guaranteed to reach the global minimum.
- D. Centroids are updated every iteration.
Tip: Fix: multiple restarts (n_init) and k-means++ initialisation.
Practise all 6 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →