2.5.5 · D4Unsupervised Learning

Exercises — Dendrograms and linkage methods

1,955 words9 min readBack to topic

This page is a self-testing workbook for the parent topic. Every problem has a hidden solution — try it first, then reveal. Problems climb from recognising the definitions to building clusterings from scratch.

Before we begin, one shared toolkit so no symbol is used before it is earned.


Level 1 — Recognition

Exercise 1.1 (L1)

Two clusters and . Their four pairwise distances are . Match each linkage to the number it would report (single / complete / average).

Recall Solution
  • Single = the smallest = (closest pair).
  • Complete = the largest = (farthest pair).
  • Average = mean of all four .

What we did: just applied "min / max / mean" to the same list of numbers — the numbers never change, only the rule that picks from them.

Exercise 1.2 (L1)

On a dendrogram, what does the height of a horizontal merge bar represent? And what does cutting the tree with a horizontal line at height give you?

Recall Solution
  • The height = the cluster-distance at the moment and merged. Low bar → merged early because they were similar; tall bar → merged late because they were dissimilar.
  • A horizontal cut at height produces as many clusters as it crosses vertical lines. Cut low ⇒ many small clusters; cut high ⇒ few big ones.

Level 2 — Application

Exercise 2.1 (L2)

, . Compute and .

Recall Solution

The four pairwise distances (see figure — two clusters as vertical bars 3 apart):

Single . Complete .

Figure — Dendrograms and linkage methods

Notice the two horizontal segments (length ) are the closest connections; the two diagonals are the farthest.

Exercise 2.2 (L2)

Same as 2.1. Compute .

Recall Solution

Sum the four . Pairs . As expected it sits between single () and complete ().

Exercise 2.3 (L2)

, . Compute .

Recall Solution

Step 1 — centroids (average of coordinates): Step 2 — squared centroid gap: Step 3 — size weight :


Level 3 — Analysis

Exercise 3.1 (L3)

Three singletons on a line: , , (1-D points). Distances: . Using single linkage, which two merge first, and what is afterwards?

Recall Solution

Smallest distance is , so merge first at height . Now the cluster vs under single linkage . So the final merge happens at height . Dendrogram: join at , then that pair joins at .

Exercise 3.2 (L3)

Same three points . Under complete linkage, recompute and explain why it differs from single.

Recall Solution

merge first at (unchanged — this is a within-step choice on identical pairwise numbers). Complete linkage: . Why higher: complete uses the farthest member (distance ), while single used the nearest member (distance ). Complete is conservative, so merges always sit at the single-linkage height.

Exercise 3.3 (L3)

Points along a line at (equally spaced) plus an outlier at . Under single linkage, describe qualitatively what happens and name the effect.

Recall Solution

The five close points chain together one gap at a time (each gap ), forming one long cluster at low heights. The outlier at stays separate until the very end (distance to its nearest neighbour). Because single linkage only needs one short bridge, a chain of intermediate points would let far-apart groups merge cheaply — this is the chaining effect. Here there's no bridge to the outlier, so it merges last and tall.


Level 4 — Synthesis

Exercise 4.1 (L4)

Build the full single-linkage dendrogram for four 1-D points . List every merge and its height.

Recall Solution

Pairwise: .

  • Merge 1 (height ): (smallest). Cluster .
  • Recompute single-link distances from : to ; to .
  • Merge 2 (height ): with .
  • Single-link to .
  • Merge 3 (height ): with → all together.

Heights in order: .

Figure — Dendrograms and linkage methods

Exercise 4.2 (L4)

Same four points , now with complete linkage. Give every merge height and contrast with 4.1.

Recall Solution
  • Merge 1 (height ): (identical first step).
  • Complete distances from : to ; to .
  • Merge 2 (height ): with .
  • Complete to .
  • Merge 3 (height ): all together.

Heights: vs single's . Every merge from step 2 on is taller or equal because complete always grabs the farthest point.

Exercise 4.3 (L4)

Using the single-linkage tree from 4.1 (heights ), where do you cut to obtain exactly 2 clusters, and what are they?

Recall Solution

Cut at any height with (say ). This line sits above the merges at and but below the merge at , so it separates the tree into and . Why: cutting removes the top-most (tallest) links that lie above ; here only the height- link is cut, splitting the top junction into its two branches.


Level 5 — Mastery

Exercise 5.1 (L5)

Two clusters and . Compute all four linkages and rank them from smallest to largest. Verify the ordering rule single average complete.

Recall Solution

Pairwise distances:

  • Single

  • Complete

  • Average

Ward: centroids ; ; weight ; so .

Ordering of the min/avg/max trio: ✓ (single average complete always holds — a mean can't beat its own min or exceed its own max). Ward lives on a different scale (squared distance) so we don't slot it in this chain.

Exercise 5.2 (L5)

From scratch, argue why single linkage can never exceed complete linkage for the same pair of clusters, and give the one case where they are equal.

Recall Solution

Let the set of pairwise distances be . Single picks , complete picks . For any non-empty finite set, by definition of min/max — so always. Equality happens exactly when , i.e. when every cross-pair distance is identical (all of is one repeated value). Geometrically: e.g. two singletons (, only one pair), or perfectly symmetric configurations where all cross-distances coincide.

Exercise 5.3 (L5)

, (an equilateral triangle of side — wait, 's point coincides with a vertex of ). Compute and comment on the size-weighting.

Recall Solution

. For : . . Weight . Comment: even though 's single point sits on a vertex of (distance to one member!), Ward reports — because Ward measures the centroid gap and the variance increase, not the nearest point. A single-linkage view here would report . This is why Ward and single can disagree drastically.


Recall Quick self-check reveals

Single linkage of , ::: Complete linkage of the same ::: First merge is identical across all linkages when every cluster is a singleton ::: True — all reduce to point-to-point distances Ward distance of :::