Professional Documents
Culture Documents
Collaborative Intelligence Ex 1
Collaborative Intelligence Ex 1
Exercise Sheet 1
Team:
Suneetha Kanoor - 391271
Exercise 6.4
package exercise1;
public class LevenshteinDistance {
private String s1,s2;
private int[][] distMatrix;
public LevenshteinDistance(String s1, String s2) {
super();
this.s1 = s1;
this.s2 = s2;
}
public void displayMatrix(int[][] matrix){
for(int i=0; i < matrix.length; i++){
System.out.print("[");
for(int j=0; j < matrix[i].length; j++){
System.out.print(matrix[i][j] + ",");
}
System.out.println("]");
}
}
public int getMinimun(int a, int b, int c){
if(a <= b && a <= c)
return a;
Output:
[0,1,2,3,4,5,]
[1,0,1,2,3,4,]
[2,1,1,2,3,4,]
[3,2,2,1,2,3,]
[4,3,3,2,1,2,]
[5,4,4,3,2,1,]
[0,1,2,3,4,5,]
[1,0,1,2,3,4,]
[2,1,1,2,3,4,]
[3,2,2,2,2,3,]
[4,3,3,3,3,2,]
[0,1,2,3,4,5,6,7,]
[1,0,1,2,3,4,5,6,]
[2,1,0,1,2,3,4,5,]
[3,2,1,0,1,2,3,4,]
[4,3,2,1,0,1,2,3,]
[5,4,3,2,1,1,2,3,]
[6,5,4,3,2,1,2,3,]
[7,6,5,4,3,2,2,3,]