Why is Partitioning Around Medoids (PAM) computationally more expensive per iteration than Lloyd's k-means?
Last updated
Lloyd's k-means updates centers in closed form (the mean), so each iteration costs O(n·k·d).
PAM's SWAP phase evaluates all k·(n−k) medoid/non-medoid swaps, each re-scoring all points, giving O(k·(n−k)²) per iteration plus O(n²) memory for the distance matrix.
The root cause is no closed-form minimizer for arbitrary dissimilarities. FasterPAM, CLARA, and CLARANS reduce the cost.