Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bddicken committed Dec 9, 2024
1 parent a46e3d6 commit d86acbc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions levenshtein/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ int levenshtein(const char *str1, const char *str2) { // A function that takes
int m = strlen(str1); // The lengths of the two strings must be ascertained somehow
int n = strlen(str2);

int **matrix = malloc((m + 1) * sizeof(int *)); // A MxN matrix must be allocated. Either stack or heap is acceptable.
for (int i = 0; i <= m; i++) {
matrix[i] = malloc((n + 1) * sizeof(int));
}
int matrix[m+1][n+1]; // A MxN matrix must be allocated. Either stack or heap is acceptable.

int matrix[m+1][n+1]; // Matrix initialization step to generate first row and column.
for (int i = 0; i <= m; i++) { // Matrix initialization step to generate first row and column.
matrix[i][0] = i;
}
for (int j = 0; j <= n; j++) {
matrix[0][j] = j;
}

for (int i = 1; i <= m; i++) { // Entire levenshtein matrix must be populated
for (int j = 1; j <= n; j++) { // Using standard / naive levenshtein algorithm
Expand Down

0 comments on commit d86acbc

Please sign in to comment.