Answer the question
In order to leave comments, you need to log in
Complexity of algorithms for determining a substring in a string?
What should the different complexity levels of algorithms look like to determine a string in another string as a substring?
Answer the question
In order to leave comments, you need to log in
They should look like the Aho-Korasik algorithm, which has linear complexity and is the most optimal.
H = |haystack|, n = |needle|, a is the size of the alphabet.
Primitive algorithm: no preprocessing, work on average 2H, maximum O(Hn).
Typical fast algorithms: O(n) or O(n+a) preprocessing, average operation <H, maximum O(Hn).
Automatic algorithms: preprocessing O(na) or O(n+a), work =H.
There are TERRIBLE algorithms with work on average <H and a maximum of O (H), where they are applied - I don’t know.
If you need to conduct several searches for the same "needle" in different "stacks", you need only one pre-processing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question