string - CLRS 32.2-2 - How to use Rabin-Karp to match k patterns of varying length at once? -
i've been trying solve following problem in clrs:
how can extend rabin-karp method find k different patterns in given text @ once? @ first assume patterns have same length, generalize allow different length string patterns.
the easier case can done using hashset - throwing hash of k patterns it, , using 1 pass through given world, can check in o(1) time, if current hash in hashset.
i'm wondering generalizing however. best approach found requires j passes through text, j number of different pattern lengths (one pass each length).
can done better? i'm looking linear time solution (o(n+m) m size of k patterns combined).
i saw using rabin-karp search multiple patterns in string, there no answer different length patterns.
Comments
Post a Comment