# Can someone please explain KMP algorithm?

**URL:** https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776
**Category:** programming
**Created:** [September 3, 2021, 1:56pm UTC](https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776 "2021-09-03T13:56:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![csstudent](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@csstudent](https://forum.kirupa.com/u/csstudent)
#### Post date: [September 3, 2021, 1:56pm UTC](https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776/1 "2021-09-03T13:56:40Z")

</div>

I am studying Knuth-Morris-Pratt algorithm. It is hard to understand. I have spent enough time online, read wiki, GeekForGeeks & TutorialsPoint. I need simple explanation for KMP algorithm & how it works in linear time. Any resource or detail explanation will be very helpful. Thank you.

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [September 4, 2021, 5:14am UTC](https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776/2 "2021-09-04T05:14:05Z")

</div>

Have you seen this one?

> **[Knuth-Morris-Pratt Algorithm | Brilliant Math & Science Wiki](https://brilliant.org/wiki/knuth-morris-pratt-algorithm/)**
>
> The KMP algorithm is an efficient string matching algorithm due to Donald Knuth, Vaughan Pratt, and James H. Morris. It is a linear time algorithm that exploits the observation that every time a match (or a mismatch) happens, the pattern itself...

---

<div class="post-metadata">

### Author: ![joziqohy](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@joziqohy](https://forum.kirupa.com/u/joziqohy)
#### Post date: [September 15, 2021, 3:08pm UTC](https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776/3 "2021-09-15T15:08:25Z")

</div>

This article from W3Spot should be helpful [KMP Algorithm Explained In Plain English – W3 Spot](https://www.w3spot.com/2020/07/kmp-algorithm-explained-in-plain-english.html)

---

<div class="post-metadata">

### Author: ![Brackwom](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Brackwom](https://forum.kirupa.com/u/Brackwom)
#### Post date: [October 23, 2021, 7:19am UTC](https://forum.kirupa.com/t/can-someone-please-explain-kmp-algorithm/648776/4 "2021-10-23T07:19:11Z")

</div>

Try this Tutorial point, I think that it helps you,  
[https://www.tutorialspoint.com/Knuth-Morris-Pratt-Algorithm](https://www.tutorialspoint.com/Knuth-Morris-Pratt-Algorithm)
