What is the most efficient algorithm to determine if array2 is a “sub-array” of array1?
(True for array1 = [9,9,10,4] and and array2 = [9, 10])
Without relying on a language-specific utility for array comparison, what’s the cheapest average and worst-case solution? It seems like sorting and binary search would only get the negative case.
This is basically about exact text matching algorithms, so we should at compare at least Boyer-Moore, KMP and Rabin-Karp string search algorithms.
Fortunately, the answer is already on this Wikpedia page, which compares the complexities (average/worst case) of several string search algorithms.