TIPS & EXPERT ADVICE ON ESSAYS, PAPERS & COLLEGE APPLICATIONS

/*  * Class Name: CalculateLevenshteinDistance * Purpose: The below code calculates Levenshtein distance using dynammic programming approach. * Reference Link for Understanding DP w.r.t Levenshtein Distance: * https://course.ccs.neu.edu/cs5800sp18wc/Memoization/editDistance1.html * */import java.util.Scanner;public class CalculateLevenshteinDistance { public static void main(String args) { //For taking User input Scanner scannerinput=new Scanner(System.in); System.out.println(“Please enter first string:”); String strFirstString=scannerinput.nextLine(); System.out.println(“Please enter second string:”); String strSecondString=scannerinput.nextLine(); //Converting both strings to lower case to calculate effective edit distance strFirstString=strFirstString.toLowerCase(); strSecondString=strSecondString.toLowerCase(); //Calculating the time taken to perform the operation. Start counter. long startTime = System.currentTimeMillis(); int intCalculatedDistance= calculateLevenshteinfunction(strFirstString,strSecondString); //Stop counter long stopTime = System.currentTimeMillis(); long timeTaken=stopTime-startTime; //Displaying the Levenshtein distance and time  taken. System.out.println(“Levenshtein Distance is : “+intCalculatedDistance+”  And Time Taken is  “+timeTaken+” ms”); } /* * Method Name:calculateLevenshteinfunction * Purpose: Calculate the Levenshtein distance by taking two strings as input * Parameters: String, String * */   public static int calculateLevenshteinfunction(String strFirstString, String strSecondString) { //Calculating the length of strings int intLengthFirst=strFirstString.length(); int intLengthSecond = strSecondString.length(); //Initializing 2D array for storing edit distance int compareStrings=new intintLengthFirst+1intLengthSecond+1; //Setting the default values in array Row from first string for(int i=0;i<=intLengthFirst;i++) { compareStringsi0=i; } //Setting the default values in array Row from second string for(int j=0;j<=intLengthSecond;j++) { compareStrings0j=j; } //Iterating the strings and settings values in 2D array for(int i=0;iintValue3) { intNewMin=intValue3; } //return the minimum value return intNewMin; }}