Optimized Algo
This commit is contained in:
parent
b6fd646b5c
commit
090dc5eabc
1 changed files with 5 additions and 3 deletions
|
|
@ -43,7 +43,7 @@ public class LevenshteinDistance {
|
||||||
* changes to equalize the two strings) for two Strings.
|
* changes to equalize the two strings) for two Strings.
|
||||||
*
|
*
|
||||||
* @param matrix is a int matrix that will be used for the dynamic programing algorithm.
|
* @param matrix is a int matrix that will be used for the dynamic programing algorithm.
|
||||||
* NOTE: matrix must be 1 larger than the larges string
|
* NOTE: matrix must be 1 larger than the largest string
|
||||||
* @return The number of changes needed to equalize the two Strings
|
* @return The number of changes needed to equalize the two Strings
|
||||||
*/
|
*/
|
||||||
public static int getDistance(String str1, String str2, int[][] matrix) {
|
public static int getDistance(String str1, String str2, int[][] matrix) {
|
||||||
|
|
@ -96,7 +96,9 @@ public class LevenshteinDistance {
|
||||||
return matrix[len1 - 1][len2 - 1];
|
return matrix[len1 - 1][len2 - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int min(int i, int j, int k){
|
private static int min(int a, int b, int c){
|
||||||
return Math.min(i, Math.min(j, k));
|
int i = (a < b) ? a : b;
|
||||||
|
return (i < c) ? i : c;
|
||||||
|
//return Math.min(i, Math.min(j, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue