Knuth-Morris-Pratt algorithm

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

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

  • @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 ปีที่แล้ว +25

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

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

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

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

    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 ปีที่แล้ว +6

      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

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

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

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

    ayyyyy lmaooo

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

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

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

    best video on KMP's out there.

  • @rlifts
    @rlifts 3 หลายเดือนก่อน

    Awesome, really helped in explaining.

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

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

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

    AYYYYYY LMAOOOO LOOOOLLLLLLL you made my night of studying hahaha

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

      what time stamp is it?

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

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

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

    Indeed best kmp tutorial.

  • @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

  • @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.

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

    Best Algorithm tutorial
    FOR KMP

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

    Very good Video

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

    Best kmp tutorial on the web.

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

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

  • @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?

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

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

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

    Excellent video!

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

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

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

    I love the outro. Thanks for the video also.

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

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

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

    This is the best tutorial in the whole of youtube !

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

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

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

    excellent video!!!!!!!!

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

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

  • @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.

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

    Best explaination... Thanks

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

    Nice one! I followed that explanation.

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

    The best tutorial by far on youtube
    Thanks!!

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

    I am in love with her voice

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

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

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

    I love these accents

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

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

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

    BEST VIDEO OF KMP.....

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

    this video help me a lot

  • @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.

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

    Nice explanation..!

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

    really good video !!

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

    Best one indeed

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

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

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

    Thank You

  • @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.

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

    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....

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

    This so clear holy shit thanks

  • @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.

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

    nice

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

    thanks☺

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

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

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

    Good Job !!!!!

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

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

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

    graet explanation

  • @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.

  • @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 ,

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

    Great explanation. The female voice is awesome.

  • @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.

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

    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 9 ปีที่แล้ว

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

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

      +Antra Bhardwaj looks like it's a mistake

  • @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.

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

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

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

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

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

    insane explanation!!!! thanks a ton!!

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

    thank you so much! i finally understand haha

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

    Spooky

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

    He girl, could you go faster than that !?

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

    cute voice

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

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

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

    thank faking god

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

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

  • @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

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

    Ayyyyyy lmao

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

    Ayyyyyy Lmaooo xD

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

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

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

    very well explained! :)

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

    Slowwwww dowwwwn.

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

    Nice overview! But pseudo code for KPM-Matcher is incorrect. It is not doing any backtracking (j should be reset if match is not found), but instead matcher just loops over all values.

  • @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