Substring search algorithms

Given text and pattern, find out appearance of pattern in given text. 

1. Knuth–Morris–Pratt(KMP) Pattern Matching, Explanation Video

2. Boyer-Moore: Example Video1, Video2

3. Rabin-Karp: Example Video 1


Related Questions:

Boyer Moore maximum voting algorithm : Explanation Video1

Approach 1: Use brute force algorithm where we can count frequency of each element. Time complexity: O(N^2) & Space complexity: 1

Approach 2: Sort the array in NLogN time and count element occurrences in O(N) time.

Approach 3: Use frequency table of elements. Time complexity: 1 & Space complexity: O(N^2)

Approach 4: Use HashMap where element as key and count as value

Approach 5: Boyer Moore maximum voting algorithm: Code, Time Complexity: O(N) & Space complexity: 1

Comments

Popular posts from this blog

SQL basic interview question

gsutil Vs Storage Transfer Service Vs Transfer Appliance