The point: k comes last
K-means and DBSCAN both need a decision before they run — how many clusters, or how dense. Hierarchical clustering needs neither. It builds one tree, and a horizontal cut through it produces a clustering.
Drag the cut height and watch the count change. A cut low down leaves many small clusters, a cut high up leaves few, and the tree itself never changed. That is genuinely useful when you do not know what structure to expect, because you can look at the merge distances before committing.
Large jumps in the curve are informative: a merge that costs much more than the one before it joined two things that were not really close. Cutting just below a big jump is the dendrogram equivalent of the [elbow](choosing_k.html).
Linkage changes everything
The algorithm needs a distance between two *clusters*, not two points, and there is no single right answer. Switch the control and the shape of the curve changes substantially.
Single linkage — distance between the nearest pair. Merges cheaply whenever any two members are close, so it can follow elongated shapes. Its failure mode is chaining: two well-separated blobs joined by a thin bridge of points merge into one, because the bridge provides a short hop at every step.
Complete linkage — distance between the furthest pair. A merge is only cheap if *every* member of one cluster is close to every member of the other, so clusters come out compact and roughly equal in diameter. It breaks up elongated structures that genuinely belong together, and is sensitive to outliers, since one distant member sets the whole distance.
Average linkage — the mean over all cross-pairs. Between the two, and the usual default.
Ward linkage, not offered here, merges the pair that increases within-cluster variance least. It behaves much like k-means and is the most common choice for roughly spherical clusters.
| Linkage | Produces | Fails at |
|---|
| Single | elongated, chain-following | bridges between clusters |
| Complete | compact, similar sized | genuinely elongated clusters |
| Average | a compromise | nothing dramatic |
| Ward | spherical, balanced | non-convex shapes |
Reading a real dendrogram
A conventional dendrogram draws each merge as a bracket at its height, with the leaves at the bottom. Two things are worth knowing about reading one.
Height is meaningful; horizontal position is not. The left-to-right order is chosen to keep the drawing untangled and carries no information. Two adjacent leaves are not necessarily similar.
The tree is greedy and permanent. Once two clusters merge they never separate, so an early mistake — two points joined because of noise — propagates all the way up. Hierarchical clustering does not revisit decisions.
Cost
The naive algorithm is O(n³), and careful implementations reach O(n² log n) with O(n²) memory for the distance matrix. That memory is usually the binding constraint: 100,000 points is a matrix of ten billion distances.
This is why hierarchical clustering is a small-to-medium-data method. Above a few tens of thousands of points, k-means or a sampled variant is the practical choice.
Where it goes wrong
Not scaling the features. As with every distance-based method.
Using single linkage on data with any bridge between clusters. Chaining will merge them.
Reading meaning into leaf order. It is a drawing convention.
Trying it on a large dataset. The distance matrix will not fit.