0% found this document useful (0 votes)
30 views1 page

Public Static Int Int New Int For Int For Int For Int For Int

This document defines a method to compute the Levenshtein distance between two strings. It initializes a 2D array to store the distance between prefixes of the two strings. It then recursively calculates the minimum distance between corresponding characters in the strings and surrounding distances, storing the results in the 2D array. The final distance is returned from the array after processing all characters.

Uploaded by

hddeveloper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Public Static Int Int New Int For Int For Int For Int For Int

This document defines a method to compute the Levenshtein distance between two strings. It initializes a 2D array to store the distance between prefixes of the two strings. It then recursively calculates the minimum distance between corresponding characters in the strings and surrounding distances, storing the results in the 2D array. The final distance is returned from the array after processing all characters.

Uploaded by

hddeveloper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

public static int computeLevenshteinDistance(String str1, String

str2) {
int[][] distance = new int[str1.length() 1][str2.length()
1]!

for (int i = "! i #= str1.length()! i)
distance[i]["] = i!
for (int $ = 1! $ #= str2.length()! $)
distance["][$] = $!

for (int i = 1! i #= str1.length()! i)
for (int $ = 1! $ #= str2.length()! $)
distance[i][$] = minimum(
distance[i % 1][$] 1,
distance[i][$ % 1] 1,
distance[i % 1][$ % 1]
((str1.char&t(i % 1) ==
str2.char&t($ % 1)) ' "
( 1))!

return distance[str1.length()][str2.length()]!
)

private static int minimum(int a, int *, int c) {
return +ath.min(+ath.min(a, *), c)!
)

You might also like