We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b510a3c commit 6657bbdCopy full SHA for 6657bbd
src/main/java/com/thealgorithms/greedyalgorithms/KCenters.java
@@ -17,6 +17,12 @@ private KCenters() {
17
18
/**
19
* Finds the maximum distance to the nearest center given k centers.
20
+ * Steps:
21
+ * 1. Initialize an array {@code selected} of size n and an array {@code maxDist} of size n.
22
+ * 2. Set the first node as selected and update the maxDist array.
23
+ * 3. For each center, find the farthest node from the selected centers.
24
+ * 4. Update the maxDist array.
25
+ * 5. Return the maximum distance to the nearest center.
26
*
27
* @param distances matrix representing distances between nodes
28
* @param k the number of centers
0 commit comments