in reply to Re: Better way to search array for elements in other array?
in thread Better way to search array for elements in other array?
Not exactly. Suppose that L is the length of the strings you are trying to match. With the naive approach the RE engine can take advantage of Boyer-Moore, so its running time should be about O(N * M / L). With the trie approach the number of times that the re engine will start trying to match is O(N), however each attempted match that fails can cost up to O(L), so your running time is potentially as high as O(N * L). (Usually you won't hit this worst case though.)
If you have a lot of strings to match, this is potentially a big win. If you have a small number of long strings to match, this is probably not a good optimization.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Better way to search array for elements in other array?
by Limbic~Region (Chancellor) on Jan 24, 2011 at 20:20 UTC |