Question

c Programming Levenshtein Distance Problem; The problem requires a matrix and that is where I'm getting...

c Programming Levenshtein Distance Problem; The problem requires a matrix and that is where I'm getting hung up, I'm not real sure on what to use to be able to execute the program properly. The program is supposed to tell the distance between two words when they are entered. This is in c

-declare two strings of maximum size WORD_LEN

-declare an integer square matrix dist with WORD_LEN+1 rows and WORD_LEN+1 columns

-read the two words to compare if the two words are equal display 0 and end the program;

-if any of the two words is empty display the length of the other and end the program;

-Initialize the dist matrix with 0 in every position.

-Initialize the first row and the first column in the matrix:

--for i going from 0 to the length of the first word included set dist[i][0] to i

--for j going from 0 to the length of the second word included  set dist[0][j] to j

-fill the remainder of the matrix (i (row) going from 1 to the length of the first word included, j (column)

- going from 1 to the lengthof the second word included) as follows:

--compute a substitution cost which is 0 if the letter at position i-1 in the first word is equal to the letter at position j-1 in the second word, and 1 otherwise.

-compute a value val which is the minimum of the threefollowing values:

o dist[i-1][j] + 1

o dist[i][j-1] + 1

o dist[i-1][j+1] plus the substitution cost previouslycomputed.set dist[i][j] to val

-Once the matrix is fully computed, the Levenshtein distance is thevalue at the bottom right corner, dist[len1][len2] if len1 is thelength of the first word and len2 the length of the second one.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
c Programming Levenshtein Distance Problem; The problem requires a matrix and that is where I'm getting...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Write the following C++ program that searches for specified words hidden within a matrix of letters....

    Write the following C++ program that searches for specified words hidden within a matrix of letters. 1) Read a file that the user specifies. The file will first specify the dimensions of the matrix (e.g., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix. 2) Following these two numbers, there will be a number of rows of letters. These letters should be read into your matrix row...

  • Using Java. Write a program that creates a “triangular” two-dimensional array A of 10 rows. The...

    Using Java. Write a program that creates a “triangular” two-dimensional array A of 10 rows. The first row has length 1, the second row has length 2, the third row has length 3, and so on. Then initialize the array using nested for loops so that the value of A[i][j] is i+j. Finally, print out the array in a nice triangular form.

  • Please help!! These are the errors I'm getting ... string_2_set - << Back Log out 1-def...

    Please help!! These are the errors I'm getting ... string_2_set - << Back Log out 1-def string_2_set(str): 2 Given a string, split it into words (based on whitespace). For each word, remove the first and last letters from the word, and insert the pair (as a two-character word) into the set. d = set() #empty set str2 -str , split(" ") #split string with space first = str2[0][0] + str2[0] [len(str2[0])-1] #first pair if(len(str2[1]) > 1): If any word is...

  • I'm having trouble sorting this square matrix (a 2d array that has number of rows and...

    I'm having trouble sorting this square matrix (a 2d array that has number of rows and same number of column n x n) using row-wise approach in C programming. Please help me program this in C to sort it using row-wise approach, here is the code: #include <stdio.h> #define MAX 100 int main() { int mat[MAX][MAX]; int i, j, m, n; int rowsum, columnsum, diagonalsum; int k; int magic = 0; int transpose[MAX][MAX]; printf("Enter the # of rows and columns...

  • I'm writing a program in java called Sokoban. I'm pretty far in, but there are a...

    I'm writing a program in java called Sokoban. I'm pretty far in, but there are a few methods that I have no idea where to go from where I am now. Method 1: /**    * Moves a box on the board.    *    * Step 1: Use your checkDelta method to check that the move is valid. Recall that there are 2    * characters that can represent a box. Step 2: Use your togglePos method to correctly...

  • I need help modifying this program. How would I make sure that the methods is being...

    I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is   //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...

  • Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme...

    Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme will work, but it is spectacularly inefficient. If both input strings have N characters, then the number of recursive calls will exceed 2N. To overcome this performance bug, we use dynamic programming. Dynamic programming is a powerful algorithmic paradigm, first introduced by Bellman in the context of operations research, and then applied to the alignment of biological sequences by Needleman and Wunsch. Dynamic programming...

  • I need help please... Intro to Programming in C – small program 8 Project objective: To...

    I need help please... Intro to Programming in C – small program 8 Project objective: To compile, build, and execute an interactive program using character arrays and string.h functions **Submit source code (prog8.c) through Canvas • One source code file (unformatted text) will be submitted • The file name must match the assignment • The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas • The code must be submitted on time in...

  • I'm using code blocks to perform this. These problems are from my C Programming Beginners book....

    I'm using code blocks to perform this. These problems are from my C Programming Beginners book. Not too familiar with C programming so any help would be great. I would like to see how it is formatted. Also, I don't understand Problem 4 at all. Thanks. 1- Create three integer variables and initialize to zero. 2- Create three float variables and initialize to zero. 3- Create three double variables and initialize to zero. 4- Create one character variables and initialize...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT