Skip to content

Commit 6657bbd

Browse files
committed
Fix
1 parent b510a3c commit 6657bbd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/thealgorithms/greedyalgorithms/KCenters.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ private KCenters() {
1717

1818
/**
1919
* 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.
2026
*
2127
* @param distances matrix representing distances between nodes
2228
* @param k the number of centers

0 commit comments

Comments
 (0)