Knuth-Morris-Pratt algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ต.ค. 2024

ความคิดเห็น • 103

  • @mohamedanisyahiaoui9239
    @mohamedanisyahiaoui9239 ปีที่แล้ว +3

    i m here in 2023 and you cannot even imagine how much you've helped me with this explanation

  • @aliabbasjaffri4596
    @aliabbasjaffri4596 9 ปีที่แล้ว +24

    I have checked out some 4-5 videos for KMP Algorithm but this video explains the algorithm in the best possible way! Great Job!

  • @caparezzzzza
    @caparezzzzza 8 ปีที่แล้ว +73

    Yeah there is an error at min 3; the shift is always prefix.value+1, at min 3 you shifted by 2 when you should had shifted by 3(prefix.value+1)

    • @branislavasandrihtodorovic5901
      @branislavasandrihtodorovic5901 7 ปีที่แล้ว +5

      That confused me too, thanks for pointing it out

    • @akshaysarkardbit
      @akshaysarkardbit 7 ปีที่แล้ว +4

      thank you for pointing that out :) its cleared my doubt.

    • @zafer9006
      @zafer9006 7 ปีที่แล้ว +3

      i think its shifted by (i-prefix.value)

    • @myhoop
      @myhoop 6 ปีที่แล้ว

      thought the same. thanks.

    • @nitsuj1001
      @nitsuj1001 4 ปีที่แล้ว

      at minute 4:05 its the same right? shift by 3 not by 2

  • @ed2023bc
    @ed2023bc 2 หลายเดือนก่อน

    Great explanation and animation, thank you. For me, this was the only video out of 4-5 that was useful.

  • @blee0820
    @blee0820 8 ปีที่แล้ว +13

    AYYYYYY LMAOOOO LOOOOLLLLLLL you made my night of studying hahaha

    • @anshuman5554
      @anshuman5554 4 ปีที่แล้ว

      what time stamp is it?

  • @csbyadgi
    @csbyadgi 8 ปีที่แล้ว +1

    Prefix suffix generation is just awsome !!!!.. thank you. brilliant video!!

  • @LordBordNoob
    @LordBordNoob 9 ปีที่แล้ว +39

    ayyyyy lmaooo

  • @JhrJasper
    @JhrJasper 8 ปีที่แล้ว +11

    This isn't KMP to my knowledge. This is just prefix search... KMP uses an additional heuristic when pre-processing the prefix array.

  • @discarded1669
    @discarded1669 ปีที่แล้ว

    it's sad there wasn't anymore uploads in the past 8years.. however, Thanks for the tutorial

  • @projekcja
    @projekcja 8 ปีที่แล้ว +4

    The worst case complexity is o(n+m), not o(nm). In the 'worst case' described where the prefix table is all 0s, every match is skipped entirely, and we get o(m) - it's actually the best case.

  • @rlifts
    @rlifts 26 วันที่ผ่านมา

    Awesome, really helped in explaining.

  • @MB-br6wf
    @MB-br6wf 2 หลายเดือนก่อน

    best video on KMP's out there.

  • @manitcse
    @manitcse 4 ปีที่แล้ว

    Best Algorithm tutorial
    FOR KMP

  • @TheCyberink
    @TheCyberink 8 ปีที่แล้ว +3

    Think I found a mistake, at 3min you conclude that the value is 2. So you shift it twice. Great, but then you have to shift it again for the usual shift you do every time (when the value in the table is 0 you also shift it once, and not 0 times)
    Then at 4:05min you found 1, and you shift it twice, which makes sense then. So I Think at 3min it is really a mistake.
    If anyone can confirm it to me that would be nice =)

    • @zihanyang7592
      @zihanyang7592 8 ปีที่แล้ว +1

      Yes, it's an obvious mistake. And I think this video is good: th-cam.com/video/5i7oKodCRJo/w-d-xo.html

    • @ryanbarry7670
      @ryanbarry7670 5 ปีที่แล้ว

      @@zihanyang7592 the same video?

  • @moisesmendes5812
    @moisesmendes5812 8 ปีที่แล้ว +3

    Awesome KMP tutorial! The best I've found. Thanks a lot. Keep doing videos like this.

  • @Imfors4ken
    @Imfors4ken 9 ปีที่แล้ว +6

    It is not clear to me... so, what is the difference between prefix 1 and 2 inside prefix table, when It in both cases shift 2 fields to right? 4:05 ... thank you for answer. Nice video!

    • @rahuljain-ty3lr
      @rahuljain-ty3lr 9 ปีที่แล้ว +8

      Daniel Perník difference is of the current matched lenth at 2:57 current length we are watching is 4 and prefix table gives us 2 so (4-2) we shift by 2.
      At 3:55 the current length we are watching is 3 and prefix table gives 1 so we shift by (3-1) so we shift by 2 in both case !!

    • @gavinsathan
      @gavinsathan 8 ปีที่แล้ว

      Step 1 Assuming the mismatch occurs when i =v, make i=Pi[v]
      Step 2 If we still have a mismatch at the new position of i, repeat step 1, else
      Step 3 The number of slots to be skipped is the value in Pi[i]
      Got it? ;)

    • @robocop6444
      @robocop6444 8 ปีที่แล้ว +1

      Thanks for the explanation - I don't think the video makes this clear, unless I am missing something.

  • @vinodrayal3968
    @vinodrayal3968 5 ปีที่แล้ว

    Indeed best kmp tutorial.

  • @lipsachhotray1021
    @lipsachhotray1021 7 ปีที่แล้ว

    finally this video saved my day!thank you for this comprehensive video!

  • @_trion
    @_trion 6 ปีที่แล้ว

    This is best explaination for KMP! :-) Thanks!

  • @ravedavedave
    @ravedavedave 7 ปีที่แล้ว +1

    I love the outro. Thanks for the video also.

  • @Budaeku
    @Budaeku 4 ปีที่แล้ว

    This video is really nicely done but the order analysis at the end is wrong as many people have mentioned and the depiction of the algorithm is also incorrect. When a character mismatch occurs at pat[i], we look at prefix[i-1] to determine how far to regress the match. This is really unfortunate.

  • @dingwenxiao2242
    @dingwenxiao2242 9 ปีที่แล้ว

    Excellent video!

  • @yooos3
    @yooos3 7 ปีที่แล้ว +2

    Great Explanation!
    Thanks a lot! Finally understood how to make the table and how pseudo code works

  • @SmitaSaysHi
    @SmitaSaysHi 6 ปีที่แล้ว

    well explained.. Understood a bit.. I will watch it again now..

  • @sripadhthota1444
    @sripadhthota1444 9 ปีที่แล้ว +1

    great video... do more videos on algorithms ..

  • @soujanyaray7560
    @soujanyaray7560 7 ปีที่แล้ว

    Best kmp tutorial on the web.

  • @MmanuChaturvedi
    @MmanuChaturvedi 9 ปีที่แล้ว +8

    KMP is O(m+n) in the worst case not O(mn).

    • @Knot2goodAtIt
      @Knot2goodAtIt 9 ปีที่แล้ว

      Mmanu Chaturvedi Actually you can get that time, just no one says that...imagine if you only shift 1 time....everytime. its the same as the naive search

    • @Oxidizer25
      @Oxidizer25 9 ปีที่แล้ว

      Knot2goodAtIt Nope, that never happens. To build the prefix table you need O(M) and to search you need 2N steps, which is O(N).
      As to why that is so, I don't want to type an essay here and I can't share links, so you should look it up (something like "is knuth-morris-pratt always linear")

    • @qiuleiray
      @qiuleiray 9 ปีที่แล้ว

      Knot2goodAtIt
      Not true for worst case n * m. The simple way to put this is that: you only access the chars in n and m only once, so the time is n + m. unlike the naive match, when there is a match on the pattern, you shift more on n instead of 1. The reason that the naive method can be m * n is because it has backtracking (matched elements are checked again). For example, if the first element is always not a match, then the naive method also only takes up n checks.

  • @stablesort
    @stablesort 4 ปีที่แล้ว +6

    I don't think you have it right - KMP's worst running time is O(m+n). When there are zeros in the "failure function" or "prefix array", you actually shift forward by the most amount. You might want to check out this explanation: th-cam.com/video/8xWrNQOC1Ts/w-d-xo.html

    • @Budaeku
      @Budaeku 4 ปีที่แล้ว +3

      Stable Sort I was thinking that was strange too. A lot of CS material on TH-cam has errors.

  • @arka.outside
    @arka.outside 8 ปีที่แล้ว +2

    This is the best tutorial in the whole of youtube !

  • @BlastedAsh
    @BlastedAsh 8 ปีที่แล้ว +1

    This video is simply incredible! Best KMP tutorial i've ever seen!

  • @himanshusoni1422
    @himanshusoni1422 7 ปีที่แล้ว +3

    The best tutorial by far on youtube
    Thanks!!

  • @hermanheinz33
    @hermanheinz33 ปีที่แล้ว

    Very good Video

  • @AlayDhagia
    @AlayDhagia 4 ปีที่แล้ว

    I cant understand at 8:40 that why do we make our currently generated prefix value = previous prefix value ?

  • @KENILDINESHPATELBCE
    @KENILDINESHPATELBCE 8 ปีที่แล้ว

    excellent video!!!!!!!!

  • @PranjalSuccessena
    @PranjalSuccessena 9 ปีที่แล้ว

    What is the difference between Boyer-Moore Heuristics and your explanation of KMP?

  • @JQiu-xg7je
    @JQiu-xg7je 8 ปีที่แล้ว +3

    The explanation is nice and clear, but the KMP has the worst case complexity of O(m+n), not O(mn). This part is not accurate.

  • @arnoldarndth7925
    @arnoldarndth7925 6 ปีที่แล้ว

    in my classes we are working with -1 somehow for the first index and some of the following.

  • @goldennboy1989
    @goldennboy1989 7 ปีที่แล้ว

    What would happen if the text was ACAT ACGACACAGA (changed the last letter)? Then the first collum in the prefix table would be 1, A, 1. So when you get a mismatch at index 1 you would align index 1 to index 1!? This can't be right....

  • @Platypusano
    @Platypusano 7 ปีที่แล้ว +5

    Why isn't ACAC a prefix at 6:46?

    • @angelbythewings
      @angelbythewings 7 ปีที่แล้ว +1

      but its not a suffix, the suffix is CACA

  • @opop8764
    @opop8764 8 ปีที่แล้ว

    this video help me a lot

  • @sukirtiarora3583
    @sukirtiarora3583 7 ปีที่แล้ว

    Best explaination... Thanks

  • @iamabean
    @iamabean 9 ปีที่แล้ว

    Woa. This tutorial offers a very intuitive way to understand the KMP. Other tutorials I have found are too wordy and use many technical jargon, which make the problem even harder to understand. Thank you so much for the video. You save my night ,

  • @MySanjukta
    @MySanjukta 8 ปีที่แล้ว +1

    BEST VIDEO OF KMP.....

  • @dhruvthakkar2018
    @dhruvthakkar2018 8 ปีที่แล้ว +1

    thanks☺

  • @pdppradeep
    @pdppradeep 7 ปีที่แล้ว

    This is an amazing KMP tutorial, very intuitive explanation.
    Thanks for taking your time in creating it.

  • @glimganz
    @glimganz 8 ปีที่แล้ว

    Thank You

  • @BiggstheCat
    @BiggstheCat 8 ปีที่แล้ว

    Nice one! I followed that explanation.

  • @hhehe24
    @hhehe24 5 ปีที่แล้ว

    I love these accents

  • @sumit550
    @sumit550 8 ปีที่แล้ว

    really good video !!

  • @mathimagery
    @mathimagery 8 ปีที่แล้ว +4

    Great explanation. The female voice is awesome.

  • @justsuyash
    @justsuyash 9 ปีที่แล้ว

    Best one indeed

  • @vetiarvind
    @vetiarvind 8 ปีที่แล้ว

    Woah you just blitzed through the pseudocode part...Guess I need to rewatch that a couple of times. Do upload more videos if you can.

    • @vetiarvind
      @vetiarvind 3 ปีที่แล้ว +1

      Lol, here i am 5 years later looking at the same code.

  • @krish0007
    @krish0007 6 ปีที่แล้ว

    Nice explanation..!

  • @burhansultan2136
    @burhansultan2136 4 ปีที่แล้ว

    hi can i get this ppt file you used for video?

  • @ahmedyassineksouda2142
    @ahmedyassineksouda2142 6 ปีที่แล้ว

    thanks you solved a big problem for me :D
    Great job!!

  • @WahranRai
    @WahranRai 8 ปีที่แล้ว +1

    He girl, could you go faster than that !?

  • @distrologic2925
    @distrologic2925 5 ปีที่แล้ว

    I am in love with her voice

  • @bluelyfe4736
    @bluelyfe4736 6 ปีที่แล้ว

    This so clear holy shit thanks

  • @DHSS1
    @DHSS1 8 ปีที่แล้ว

    Good Job !!!!!

  • @gauravgupta4543
    @gauravgupta4543 2 ปีที่แล้ว

    nice

  • @antrabhardwaj945
    @antrabhardwaj945 8 ปีที่แล้ว

    when G is mismatched with A .. then why u shifted by 2..
    as in the prefix table it should be shifted by 1 ??

    • @1Bassmasta1
      @1Bassmasta1 8 ปีที่แล้ว

      +Antra Bhardwaj word, cant understand why.....

    • @Suldok
      @Suldok 8 ปีที่แล้ว

      +Antra Bhardwaj looks like it's a mistake

  • @samarthseth6140
    @samarthseth6140 8 ปีที่แล้ว

    Great explanation!!
    I watched about 4-5 KMP videos but couldn't understand much, but this one i did.

  • @LyssusX
    @LyssusX 8 ปีที่แล้ว +1

    thank you so much! i finally understand haha

  • @vijayalakshmiv3567
    @vijayalakshmiv3567 4 ปีที่แล้ว

    graet explanation

  • @AP-eh6gr
    @AP-eh6gr 9 ปีที่แล้ว +2

    insane explanation!!!! thanks a ton!!

  • @ravedavedave
    @ravedavedave 7 ปีที่แล้ว +1

    Ayyyyyy lmao

  • @amerkiller1995
    @amerkiller1995 8 ปีที่แล้ว +11

    cute voice

  • @sarthaksharma9322
    @sarthaksharma9322 6 ปีที่แล้ว

    Great Video, Just awesome explanation with great visual support👍👍

  • @rodrigomontoya8653
    @rodrigomontoya8653 3 ปีที่แล้ว

    what program did you guys use to make those shapes, tables, and everything? i have to do a video similar to this about text search algorithm but paint is driving me crazy

  • @khoidiep1001
    @khoidiep1001 4 ปีที่แล้ว

    Ayyyyyy Lmaooo xD

  • @jonasls
    @jonasls ปีที่แล้ว

    Spooky

  • @samim.5091
    @samim.5091 4 ปีที่แล้ว

    Weird outro but it's from 2014 so I'll take it

  • @SubhamMahato39
    @SubhamMahato39 6 ปีที่แล้ว

    please do one for Rabin Karp !
    You people are excellent educators !

  • @djdeustch1788
    @djdeustch1788 6 ปีที่แล้ว

    The pseudocode code is not totally O(n+m) like...

  • @ShortStack312
    @ShortStack312 6 ปีที่แล้ว

    thank faking god

  • @michaelschrempp559
    @michaelschrempp559 8 ปีที่แล้ว

    very well explained! :)

  • @denisfrolov242
    @denisfrolov242 4 ปีที่แล้ว

    Slowwwww dowwwwn.

  • @nadav6213
    @nadav6213 ปีที่แล้ว +1

    it isn't KMP algorithm, delete the video at least

  • @comuniomeister
    @comuniomeister ปีที่แล้ว

    Good video but not well spoken in english for internationals

  • @vikramsehgal1999
    @vikramsehgal1999 3 ปีที่แล้ว

    ayyyyyy lmao