public void Search() { Assert.IsTrue(KMPSearch.Search("abd", "abdfgh").SequenceEqual(new List <int> { })); /* Testing the case where substring is longer than string. */ Assert.AreEqual(1, KMPSearch.Search("abcd", "bc")[0]); Assert.AreEqual(2, KMPSearch.Search("abcd", "cd")[0]); Assert.AreEqual(12, KMPSearch.Search("aaaaaakcdkaaaabcd", "aab")[0]); Assert.IsTrue(KMPSearch.Search("abcaab", "a").SequenceEqual(new List <int> { 0, 3, 4 })); Assert.IsTrue(KMPSearch.Search("abcaab", "abc").SequenceEqual(new List <int> { 0 })); Assert.AreEqual(0, KMPSearch.Search("aaabbbdaacbb", "kjh").Count); }
static void Main(string[] args) { string[] a = { "abv", "abd", "abc", "afr", "abt", "ayv", "bvc", "ayc" }; var b = a; //LSD.Sort(a, 3); MSD.Sort(b); int i = ForceSearch.Search1("ll", "hello"); KMPSearch kmp = new KMPSearch("llo"); i = kmp.Search("hello"); Console.ReadKey(); }