Java LCS LCSRecursive(Character[] X, int i, Character Y[], int j, int c[][])

Here you can find the source of LCSRecursive(Character[] X, int i, Character Y[], int j, int c[][])

Description

LCS Recursive

License

Open Source License

Declaration

private static int LCSRecursive(Character[] X, int i, Character Y[],
            int j, int c[][]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static int LCSRecursive(Character[] X, int i, Character Y[],
            int j, int c[][]) {
        if (c[i][j] == Integer.MIN_VALUE) {
            if (X[i - 1].equals(Y[j - 1])) {
                c[i][j] = 1 + LCSRecursive(X, i - 1, Y, j - 1, c);
            } else {
                c[i][j] = Math.max(LCSRecursive(X, i - 1, Y, j, c),
                        LCSRecursive(X, i, Y, j - 1, c));
            }/*from  w w w. j a  v  a 2s .  co  m*/
        }
        return c[i][j];
    }
}

Related

  1. lcs3(int[] A, int[] B)
  2. lcs4(int[] A, int[] B)
  3. LCSAlgorithm(String a, String b)
  4. lcse(String str1, String str2)
  5. LCSIterative(Character[] X, int i, Character Y[], int j, int c[][])