Documentation of 'edu.princeton.cs.algs4.LongestCommonSubstring' Java class
LongestCommonSubstring
edu.princeton.cs.algs4

Class LongestCommonSubstring



  • public class LongestCommonSubstring
    extends java.lang.Object
    The LongestCommonSubstring class provides a SuffixArray client for computing the longest common substring that appears in two given strings.

    This implementation computes the suffix array of each string and applies a merging operation to determine the longest common substring. For an alternate implementation, see LongestCommonSubstringConcatenate.java.

    For additional documentation, see Section 6.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String lcs(java.lang.String s, java.lang.String t)
      Returns the longest common string of the two specified strings.
      static void main(java.lang.String[] args)
      Unit tests the lcs() method.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • lcs

        public static java.lang.String lcs(java.lang.String s,
                                           java.lang.String t)
        Returns the longest common string of the two specified strings.
        Parameters:
        s - one string
        t - the other string
        Returns:
        the longest common string that appears as a substring in both s and t; the empty string if no such string
      • main

        public static void main(java.lang.String[] args)
        Unit tests the lcs() method. Reads in two strings from files specified as command-line arguments; computes the longest common substring; and prints the results to standard output.
        Parameters:
        args - the command-line arguments

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.