Did anyone work on KMP algorithm? Plz explain it

Off-topic posts of interest to the "Everything" community.
Post Reply
lul123
Posts: 2
Joined: Tue Aug 23, 2022 4:39 pm

Did anyone work on KMP algorithm? Plz explain it

Post by lul123 »

I am learning different pattern searching algorithms. I am kind of stuck with KMP algorithm. I am not able to understand how the time complexity is O(m+n). I think I am not fully getting how the steps work for this algorithm. I already tried multiple resources. It would be helpful if someone who worked on it can explain it in easier terms.
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Did anyone work on KMP algorithm? Plz explain it

Post by void »

Everything doesn't use the KMP algorithm.

Typically Everything searches are small, so KMP will offer no real-world performance increase.

KMP Algorithm for Pattern Searching
lul123
Posts: 2
Joined: Tue Aug 23, 2022 4:39 pm

Re: Did anyone work on KMP algorithm? Plz explain it

Post by lul123 »

Thanks @void.
I found another article which was a bit simpler to understand https://www.w3spot.com/2020/07/kmp-algo ... glish.html, but it doesn't have code implementation like the one you shared.
Post Reply