Greedy Algorithms

Created

Coin Changing

Goal: Given U.S, Currency denominations 1,5,10,25,100{1, 5, 10, 25, 100}, devise a method to pay amount to cusotmer using the fewest coins.

Cashier's Algorithm

Cashier's algorithm: at each itearation add coin of the largets value that does not take us past the amount to be paid:

Sort nn coin denominations so that 0<c1<c2<⋯<cn0 < c_1 < c_2 < \cdots < c_n S ←∅\leftarrow \varnothing (multiset of coins selected).

While x>0x>0,

  • k←k \leftarrow largest coin denomination ckc_k such that ck≤xc_k \leq x.

  • If (no such kk)

    • Return "no solution"
  • Else

    • x←x−ckx \leftarrow x - c_k.
    • s←S∪ks \leftarrow S \cup {k}

Return SS

Cashier's Algorithm is not always optimal.

The properties of any optimal solutions (for U.S. coin denominations):

  • the number of pennies ≤4\leq 4 (proof: replace 5 pennies with 1 nickel)
  • number of nickels ≤1\leq 1.
  • number of quarters ≤3\leq 3
  • number of nickels + dimes ≤2\leq 2 (proof: ≤1\leq 1 nickel, replace 3 dimes and 0 nickels with 1 quarter and 1 nickel; replace 2 dimes and 1 nickel with 1 quarter)

The optimality of cashier's algorithm (for U.S. coin denominations):

theorem: cashieer's algoirthm is optimal for U.S. coins {1,5,10,25,100}\{1,5,10,25,100\} proof (by induction on amount to be paid xx)

  • consider the optimal way to change ck≤x≤ck+1c_k \leq x \leq c_{k+1}: greedy takes coin kk.
  • We claim that any optimal solution must take coin kk.
    • if not, it needs enough coin of type c1,⋯ ,ck−1c_1, \cdots, c_{k-1} to add up to xx.
    • table below indicates no optimal solution can do this.
  • Problem reduces to coin-changing x−c+kx-c+k cents, which, by induction, is optimally solved by cahsier's algorithm.

Interview Scheduling

Job jj starts at sjs_j and finishes at fif_i. Two jobs are compatible if they don't overlap. Goal: find the maximum subset of mutually compatible jobs.

Earliest Finish Time First Algorithm

Earliest-finish-time-first (n,s1,s2,⋯ ,sn,f1,f2,⋯ ,fnn, s_1, s_2, \cdots, s_n, f_1, f_2, \cdots, f_n)

Sort jobs by finish tmes and renumber so that f1≤f2≤⋯≤fnf_1 \leq f_2 \leq \cdots \leq f_n. S ←∅\leftarrow \varnothing (set of jobs selected). For j=1j = 1 to nn

  • If (job jj is compatible with SS)
  • s←S∪{j}s \leftarrow S \cup \{j\}

Return SS.

Preposition: can implement earliest-finish-time first in O(nlog⁡n)O(n\log n) time.

  • keep track of job j∗j* that was added last to SS.
  • Job jj is compatible with SS iff sj≥fj∗s_j \geq f_{j*}
  • Sorting by finish times takes O(nlog⁡n)O(n \log n) time.

Theorem: the earliest-finish-time-first algorithm is optimal. Proof (by contradiction):

  • assume greedy is not optimal, and let's see wha thappens
  • Let i1,i2,⋯iki_1, i_2, \cdots i_k denote the set of jobs selected by greedy.
  • Let j1,j2,⋯ ,jmj_1, j_2, \cdots, j_m denote thes et of jobs in an optimal solution with i1=j1,i2=j2,⋯ ,ir=jri_1 = j_1, i_2 = j_2, \cdots, i_r = j_r for the largest possible value of rr.

Interval Partitioning

Lecture jj starts at sjs_j and finishes at fjf_j.

Goal: find minimum number of classrooms to schedule all lectures so that no two lectures occur at the same time in the same room.

Earliest-start-time-first (n,s1,s2,⋯ ,sn,f1,f2,⋯ ,fnn, s_1, s_2, \cdots, s_n, f_1, f_2, \cdots, f_n)

Sort lectures by start times and renumber so that s1≤s2≤⋯≤sns_1 \leq s_2 \leq \cdots \leq s_n d←0d \leftarrow 0 (number of allocated classrooms)

For j=1j = 1 to nn,

  • If (leucture jj is compatible with some classroom)
    • Schedule lecture jj in any such classroom kk.
  • Else
    • Allocate a new classroom d+1d+1.
    • Schedule lecutre jj in classroom d+1d+1
    • d←d+1d \leftarrow d+1.
  • Return schedule

Lower bound on optimal solution: the depth of a set of open intervals is the maximum number of intervals that contain any given point.

  • the number of classrooms needed ≥\geq depth.

Q: does the minimum number of classrooms needed always equal depth? A: Yes! Moreover, earliest-start-time-first algorithm finds a schedule number of classroom equals the depth.

Analysis: the earliest-start-time-first algorithm never schedules two incompatible lectures in the same classroom.

  • Theorem: earliest-start-time-first algorithm is optimal.
  • Proof:
    • let d=d = number of classrooms that the algorithm allocates.
    • Classroom dd is opened because we needed to schedule a lecture, say jj, that is incompatible with a lecture in each of d−1d-1 other classrooms.
    • Thus, these dd lectures each end after sjs_j.
    • Since we sorted by start time, each of these incompatible lecture in each of these incompatible lectures start no later than sjs_j.
    • Thus, we have dd lectures overlapping at time sj+εs_j + \varepsilon.
    • Key observation →\rightarrow all schedules use ≥d\geq d classrooms.

Scheduling to minimize lateness.

Single resource processes one job at a time. Job jj requires tjt_j units of processing time and is due at djd_j. If jj starts at time sjs_j, it finishes at time fj=sj+tjf_j = s_j+t_j. Lateness = ℓ=max{0,fj−dj}\ell = max \{ 0, f_j - d_j \}. Goal: schedule all jobs to minimize maximum lateness L=maxjℓjL=max_j \ell_j.

Earliest-Deadline-First (n,t1,t2,⋯ ,tn,d1,d2,⋯ ,dnn,t_1, t_2,\cdots, t_n, d_1, d_2, \cdots, d_n): Sort jobs by due times and renumber so that d1≤d2≤⋯≤dnd_1 \leq d_2 \leq \cdots \leq d_n. t←0t \leftarrow 0. For j=1j=1 to nn:

  • Assign job jj to interval [t,t+tjt, t+t_j]
  • sj←ts_j \leftarrow t; fj←t+tjf_j \leftarrow t + t_j.
  • t←t+tjt \leftarrow t+ t_j

Return intervals [s1,f1],[s2,f2],⋯ ,[sn,fn][s_1, f_1],[s_2, f_2],\cdots,[s_n, f_n]

We want no idle time.

  • Observation 1: there exists an optimal schedule with no idle time.
  • Observation 2: the earliest-deadline-first schedule has no idle time.

Inversions: given a schedule SS, an inversion is a pair of jobs ii and jj such that: i<ji < j but jj is scheduled before ii.

Observation 3: the earliest-deadline-first schedule is the unique idle-free schedule with no inversions.

Observation 4: if an idle-free schedule has an inversion, then it has an adjacent inversion (two inverted jobs scheduled consecutively). The proof is as follows:

  • let i−ji-j be a closeset inversion
  • let kk be element immediately to the rght of jj.
  • case 1: [j>k][j>k] then j−kj-k is an adjacent inversion
  • case 2: [j<k][j<k] then i−ki-k is a closer inversion since i<j<ki < j< k.

Key claim: exchanging two adjacent, inverted jobs ii and jj reduces the number of inversions by 1 and does not increase the max lateness.

Proof: let ℓ\ell be the lateness before the swal and let ℓ′\ell' be it afterwards.

  • ℓk′=ℓk\ell'_k = \ell_k for all k≠i,jk \neq i, j
  • ℓ′′≤ℓi\ell'' \leq \ell_i
  • If job jj is late, ℓj′=fj′−dj\ell'_j = f'_j - d_j (by definition)
    • ℓj′=fi−dj\ell'_j = f_i - d_j (jj now finishes at time fif_i)
    • ℓj′≤fi−di\ell'_j \leq f_i - d_i (i<j→di≤dji<j \rightarrow d_i \leq d_j)
    • ℓj′≤ℓi\ell'_j \leq \ell_i (by definition)

Analysis

Theorem: the earliest-deadline-first schedule SS is optimal. Proof by contradiction: Define S∗S* to be an optimal schedule with the fewest inversion (optimal schedule can have inversions).

  • Can assume S∗S* has no idle time (by observaion 1)
  • Case 1: [S∗S* has no inversions] then S=S∗S=S* (by observation 3)
  • Case 2: [S∗S* has an inversion]
    • Let i−ji-j be an adjacent inversion (by observation 4)
    • Exchanging jobs ii and jj decreases the number of inversions by 1 without increasing max lateness (key claim)
    • contradicts "fewest inversions" part of the definition of S∗S*.

Greedy Analysis Strategy

Greedy algorithm stays ahead. Show that after each step of the greedy algorithm, its solution is at least as good as any other algorithm's.

Structural: discover a simple "structural" bound asserting that every possible solution must have a certain value. Then show that your algoirthm always achieves this bound.

Exchange argument: gradually transofrm any solution to the one you found by the greedy algirhtm without hurting its quality.

The other greedy algorithms: gale-shapley, kruskal, prim, dijkstra, huffman,...

Dijkstra's Algorithm

The Problem

The Single-pair shortest path problem: Given a diagraph G=(V,E)G = (V,E), edge lengths ℓe≥0\ell_e \geq 0, source s∈Vs \in V, and destination t∈Vt \in V, find a shortest directed path from ss to tt.

The Single-source shortest path problem: Given a diagraph G=(V,E)G = (V,E), edge lengths ℓe≥0\ell_e \geq 0, source s∈Vs \in V, and find a shortest directed path from ss to every node.

Dijkstra's Algorithm (for single-source shortest paths problem): The greedy approach: maintain a set of explored nodes SS for which algorithm has determined d[u]=d[u]= length of a shortest s⇝us\rightsquigarrow u path.

  • initialize S←{s}S \leftarrow \{s\}, d[s]←0d[s] \leftarrow 0.
  • repeatedly choose unexplored node v∉Sv \notin S which minimizes π(v)=min⁡e=(u,v):u∈Sd[u]+ℓe\pi (v) = \underset{e = (u,v): u \in S}{\min} d[u] + \ell_e (the length of a shortest path from ss to some node uu in explored part SS, followed by a single edge e=(u,v)e = (u,v)). add vv to SS, and set d[v]←π(v)d[v] \leftarrow \pi(v).
  • To recover path, set pred[v]←epred[v] \leftarrow e that achieves min.

Proof of correctness:

Invariant: for each node u∈S:d[u]u \in S: d[u] = length of a shortest s⇝us\rightsquigarrow u path. Proof by induction on ∣S∣|S|:

  • base case: ∣S∣=1|S| = 1 is easy since S={s}S = \{s\} and d[s]=0d[s]=0
  • inductive hypothesis: assume true for ∣S∣≥1|S| \geq 1
    • let vv be the next node added to SS, and let (u,v)(u,v) be the final edge.
    • a shortest s⇝us\rightsquigarrow u path plus (u,v)(u,v) is an s⇝vs\rightsquigarrow v path of length π(v)\pi(v).
    • Consider any other s⇝vs\rightsquigarrow v path PP. We show that it is no shorter than π(v)\pi(v).
    • Let e=(x,v)e = (x,v) be the first edge in PP that leaves SS, and let P′P' be the subpath from ss to xx.
    • The length PP is already ≥π(v)\geq \pi(v) as soon as it reaches yy.

ℓ(P)≥ℓ(P′)≥d[x]+ℓe≥π(y)≥π(v)\ell (P) \geq \ell(P') \geq d[x] + \ell _e \geq \pi(y) \geq \pi (v)

  • explanation for each ≥\geq sign:
    • non-negative lengths
    • induction hypothesis
    • definition of π(y)\pi(y)
    • dijkstra chose vv instead of yy.

Efficient Implementation

Critical optimization 1: for each unexplored node v∉Sv \notin S: explicitly maintain π[v]\pi[v] instead of computing directly from definition: π(v)=min⁡e=(u,v):u∈Sd[u]+ℓe\pi (v) = \underset{e = (u,v): u \in S}{\min} d[u] + \ell_e

  • For each v∉S:pi(v)v \notin S:pi(v) can only decrease (because set SS increases).
  • More specifically, suppose uu is added to SS and there is an edge e=(u,v)e = (u,v) leaving uu. Then, it suffices to update: π[v]←min{π[v],π[u]+ℓe}\pi[v] \leftarrow min \{\pi[v], \pi[u] + \ell_e\} (recall: for each u∈Su \in S, pi[u]=d[u]=pi[u] = d[u] = length of shortest s⇝us\rightsquigarrow u path).

Critical optimization 2: use a min-oriented priority queue (PQ) to choose an unexplored node that minimizes π[v]\pi[v].

Implementation:

  • Algorithm maintains π[b]\pi[b] for each node vv.
  • Priority queue stores unexplored nodes, using π[⋅]\pi[\cdot] as priorities.
  • Once uu is deleted from the PQ, π[u]=\pi[u] = length of a shortest s⇝us\rightsquigarrow u path.

Dijkstra (V,E,ℓ,s)(V, E, \ell, s): For each v≠s:π[v]←∞v \neq s: \pi[v] \leftarrow \infty, pred[v]←nullpred[v] \leftarrow null; π[s]←0\pi[s] \leftarrow 0.

  • Create an empty priority queue pqpq. For each v∈Vv \in V: insert (pq,v,π[v])(pq, v, \pi[v]). While (is-not-empty(pqpq)):
  • u←u \leftarrow del-min(pq)(pq)
  • Foreach edge e=(u,v)∈Ee = (u,v) \in E leaving uu:
    • If (π[v]>π[u]+ℓe\pi[v] > \pi[u] + \ell_e)
      • Decrease-key (pq,v,π[u]+ℓepq, v, \pi[u] + \ell_e)
      • π[v]←π[u]+ℓe\pi[v] \leftarrow \pi[u] + \ell_e; pred[v]←epred[v] \leftarrow e

Minimum Spanning Trees

A path is a sequence of edges which connects a sequence of nodes.

A cycle is a path with no repeated nodes or edges other than the starting and ending nodes.

Example Path P={(1,2),(2,3),(3,4),(4,5),(5,6)}P = \{ (1,2), (2,3), (3,4),(4,5),(5,6)\}

A cut is a partition of the nodes into two nonempty subsets SS and V−SV-S. The cutset of a cut SS is the set of edges with exactly one endpoint in SS.

Cycle-cut intersection proposition: a cycle and a cutset intersect in an even number of edges.

  • A cycle and a cutset intersect in an even number of edges.

Let H=(V,T)H = (V,T) be a subgraph of an undirected graph G=(V,E)G = (V,E). HH is a spanning tree of GG if HH is both acyclic and connected.

Some properties of spanning trees. Proposition: Let H=(V,T)H = (V,T) be a subgraph of an undirected graph G=(V,E)G=(V,E). Then, the following are equivalent:

  • HH is a spanning tree of G
  • HH is acyclic and connected
  • HH is connected and has ∣V∣−1|V|-1 edges
  • HH is acyclic and has ∣V∣−1|V|-1 edges
  • HH is minimally connected: removal of any edge disconnects it
  • HH is maximally acyclic: addition of any edge creates a cycle.

Given a connected, undirected graph G=(V,E)G = (V,E) wih edge costs cec_e, a minimum spanning tree (V,T)(V,T) is a spanning tree of GG such that the sum of the edge costs in TT is minimized.

Cayley's Theorem: the complete graph on nn nodes has nn−2n^{n-2} spnaninng trees (can't be solved by brute force).

Fundamental cycle: Let H=(V,T)H=(V,T) be a spanning tree of G=(V,E)G =(V,E).

  • for any non tree-edge e∈E:T∪ee \in E: T \cup {e} contains a unique cyce, say CC.
  • for any edge f∈C:(V,T∪e−f)f \in C:(V,T \cup {e} - {f}) is a spanning tree

Observation: if ce<cfc_e < c_f, then (V,T)(V,T) is not an MST.

Fundamental cutset: let H=(V,T)H=(V,T) be a spanning tree of G=(V,E)G = (V,E).

  • for any tree edge f∈T:(V,T−f)f \in T: (V, T-{f}) has two connected components.
  • Let DD denote corresponding cutset.
  • For any dge e∈D:(V,T−F∪e)e\in D:(V,T- {F} \cup {e}) is a spanning tree.

In any cutset, the edge with minimum weight must be in every MST.

The Greedy MST Algorithm

  • red rule:
    • let CC be a cycle with no red edge.
    • select an uncolored edge of CC of max cost and color it red.
  • blue rule:
    • let DD be a cutset with no blue edges
    • select an uncolored edge in DD of min cost and color it blue.
  • greedy algorithm:
    • apply the red and blue rules (nondeterministically), until all edges are colored. The blue edges form an MST.
    • note: can stop once n−1n-1 edges colored blue.

Greedy algorithm: proof of correctness Color invariant: the exists an MST (V,T∗)(V, T*) containing every blue edge and no red edge Proof by indction on number of iterations.

  • Base case: no edge colored -> every MST satisfies invariant
  • Induction step (blue rule): suppose color invariant true before blue rule
    • let DD be a chosen cutset, and let ff be edge colored blue.
    • if f∈T∗f \in T*, then T∗T* still satisfiies invarant
    • otherwise, consider fundamental cycle CC by adding ff to T∗T*.
    • let e∈Ce \in C be another edge in DD.
    • ee is uncolored and ce≥cfc_e \geq c_f since
      • e∈T∗→ee \in T* \rightarrow e not red
      • blue rule →e\rightarrow e not blue and ce≥cfc_e \geq c_f
    • Thus, T∗∪f−eT* \cup {f} - {e} satisfies invariant
  • Induction step (red rule): suppose color invariant true before red rule
    • let CC be chosen cycle, and let ee be edge colored red
    • if e∉T∗e \notin T*, then T∗T* still satisfies invariant
    • Otherwise, consider fundamental cutset DD by deleting ee from T∗T*.
    • let f∈Df \in D be another edge in CC
    • ff is uncolored and ce≥cfc_e \geq c_f since
      • f∉T∗→ff \notin T* \rightarrow f not blue
      • red rule →f\rightarrow f not red and ce≥cfc_e \geq c_f
    • Thus, T∗∪f−eT* \cup {f} - {e} satisfies invariant.

Theorem: the greedy algorithm termiantes. Blue edges form an MST. Proof: we need to show that either the red or blue rule (or both) applies.

  • suppose edge ee is left uncolored
  • blue edge form a forest
  • Case 1: both endpoints of ee are in the same blue tree →\rightarrow apply red rule to cycle formed by adding ee to blue forrest.
  • Case 2: both endpoints of ee are in different blue trees. →\rightarrow apply blue rule to cutset induced by either of two blue trees.

Special cases are the Prim, Kruskal, reverse-delete, and more.

Prim's Algorithm

Initialize S={s}S=\{s\} for any ndoe ss, T=∅T = \varnothing Repeat n−1n-1 times:

  • add to TT a min-cost edge with exactly one endpoint in SS.
  • Add the other endpoint to SS.

Theorem: Prim's algorithm computes an MST. Proof: special case of greedy algorithm (blue rule repeatedly applied to S) (by construction, edges in cutset are uncolored).

Implementation

Theorem: prim's algorithm can be implemented to run in O(mlog⁡n)O(m \log n) time. Proof: implementation almost identical to Dijkstra's algorithm.

Prim (V,E,c): S←∅,T←∅S \leftarrow \varnothing, T \leftarrow \varnothing s←s \leftarrow any node in V.

Fo each v≠s:π[v]←∞v \neq s: \pi[v] \leftarrow \infty, pred[v]←nullpred[v] \leftarrow null; π[s]←0\pi[s] \leftarrow 0. Create an empty priority queue pqpq. For each v∈V:v \in V: insert(pq,v,π[v]pq, v, \pi[v]) While (is-not-empty(pqpq))

  • u←u \leftarrow del-min(pqpq)
  • S←S∪{u},T←T∪{pred[u]}S \leftarrow S \cup \{u\}, T \leftarrow T \cup \{pred[u]\}
  • For each edge e=(u,v)∈Ee=(u,v) \in E with v∉Sv \notin S:
    • If (ce<π[v]c_e < \pi[v])
      • Decrease-key(pq,v,cepq, v, c_e)
      • π[v]←ce\pi[v] \leftarrow c_e; pred[v]←epred[v] \leftarrow e.

Kruskal's Algorithm

Consider edges in ascending order of cost: add to tree unless it would create a cycle.

Theorem: kruskal's algorithm computes an MST. Proof: special case of greedy algorithms.

  • Case 1: both endpoints of ee in same blue tree, ⇒\Rightarrow color ee red by applying red rule to unique cycle (all other edges in cycle are blue).
  • Case 2: both endpoints of ee in different blue trees ⇒\Rightarrow color ee blue by applying blue rule to cutset defined by either tree (no edge in cutset has smaller cost since Kruskal chose it first)

Implemetation

Theorem: Kruskal's algorithm can be implemented to run in O(mlog⁡m)O(m \log m) tme.

  • Sort edges by cost
  • Use union-find data structure to dynamically maintain connected commponents.

The algorithm:

Kruskal (V,E,c) Sort mm edges by cost and renumber so that c(e1)≤c(e2)≤⋯≤c(em)c(e_1) \leq c(e_2) \leq \cdots \leq c(e_m). T←∅T \leftarrow \varnothing. For each i=1i=1 to mm:

  • (u,v)←ei(u,v) \leftarrow e_i
  • If (find-set(uu) ≠\neq find-set(vv)) (are u and v in same component)
    • T←T∪eiT \leftarrow T \cup {e_i}
    • Union(u,vu,v) (make uu and vv in the same component). Return TT.

Reverse-Delete Algorithm

Start with all the edges in TT and consider them in descending order of cost: delete edge from TT unless it would disconnect TT.

Theorem: the reverse-delete algorithm computes an MST. Proof: special case of greedy algorithm:

  • Case 1 (deleting edge ee does not disconnet TT) ⇒\Rightarrow apply red rule to cycle CC formed by adding ee (no edge in CC is more expensive since it would already been considered and deleted) to another path in TT between its two endpoints
  • Case 2 (deleting edge ee disconnects TT) ⇒\Rightarrow apply blue rule (ee is the only remaining edge in the cutset as all other edges in DD must haev been colored red / deleted) to cutset DD induced by either component.

Borůvka′s algorithm

Repeat until only one tree

  • apply blue rule to cutset corresponding to each blue tree
  • color all selected edges blue

Theorem: Borůvka′s algorithm computes the MST (assume edge costs are distinct) Proof: special case of greedy algorithm (repeatedly apply blue rule)

Implementation

Theorem: Borůvka′s algorithm can be implemented to run in O(mlog⁡n)O(m \log n) tme. Proof:

  • to implement a phase in O(m)O(m) time:
    • compute connected components of blue edges
    • for each edge (u,v)∈E(u,v) \in E, check if uu and vv are different components; if so, update each component's best edge in cutset
    • ≤log⁡2\leq \log_2 phases since each phase (at least) halves total # components.

Single-Link Clustering

Clustering The goal: given a set UU of nn objects labeled p1,⋯ ,pn,p_1, \cdots, p_n, partition into clusters so that objects in different clusters are far apart.

Applications:

  • routing in mobile ad-hoc networks
  • document cateogrization for web seraches
  • similarity searching in medical image databases
  • cluster celstial objects into stars, quasars, galaxies.

Clustering of maximum spacing k-clustering: divide objects into kk non-empty groups.

Distance function: numeric value specifying "closeness" of two obejcts:

  • d(pi,pj)=0d (p_i, p_j) = 0 iff pi=pjp_i = p_j (identity of indiscernibles)
  • d(pi,pj)≥0d(p_i, p_j) \geq 0
  • d(pi,pj)=d(pj,pi)d(p_i, p_j) = d(p_j, p_i) (symmetry)

Spacing: min distance between any pair of points in different clusters Goal: given an integer kk, find a kk-clustiering of maximum spacing.

Greedy Clustering Algorithm

"Well-known" algorithm in science literature for single-linkage kk-clustering:

  • form a graph on the node set UU, crresponding to nn clusters.
  • find the closest pair of objects such that each objet is in a different cluster, and add an edge between them
  • repeat n−kn-k times (until there are exactly kk clusters).

Key observation: this procedure is precisely Kruskal's algorithm (except we stop when there are kk connected components).

Alternative: find an MST and delete the k−1k-1 longest edges.

Greedy Cluster Algorithm: Analysis Theorem: let C∗C* denote the clustering C1∗,⋯ ,C∗kC_1* , \cdots, C*_k formed by deleting the k−1k-1 longets edges of an MST. Then, C∗C* is a kk-clustering of max spacing. Proof:

  • Let CC denote any other clustering C1,⋯ ,CkC_1, \cdots, C_k
  • Let pip_i and pjp_j be in the same cluster in C∗C*, say C∗rC*_r, but different clusters in CC, say CsC_s and CtC_t.
  • Some edge (p,qp,q) on pi−pjp_i - p_j path in C∗rC*_r spans two different clusters in CC. (this is the edge kruskal would have added next had we not stopped)
  • Spacing of C∗=C* = length d∗d* of the (k−1k-1)st longets edge in MST.
  • Edge (p,qp,q) has length ≤d∗\leq d* since it was added by Krusal
  • Spacing of CC is ≤d∗\leq d* since pp and qq are in different clusters