Z Algorithm Z values

  Рет қаралды 160,413

Tushar Roy - Coding Made Simple

Tushar Roy - Coding Made Simple

Күн бұрын

Пікірлер: 146
@code-for-mars
@code-for-mars Жыл бұрын
even the paid course don't teach you with this much perfection hats off to tushar for this and many other videos like this .
@siddheshshinde4850
@siddheshshinde4850 2 жыл бұрын
This video is absolutely perfect. Everything is explained very well from the fundamentals to the implementation part.
@shahinshahsavari1275
@shahinshahsavari1275 4 жыл бұрын
I spent so much time trying to understand this from someone else's the source code. Watching this cleared up all my confusions. Thanks!
@yogeshyogesh8789
@yogeshyogesh8789 8 жыл бұрын
Brother, I have started exploring String Algorithms few days back and , believe me , this is best resource I have found so far on the whole internet.
@Aditya-wj5gy
@Aditya-wj5gy Жыл бұрын
Thanks for such a wonderful explanation. This algo is one of the hardest as there are many variables you need to track and requires practice.
@sanketneema286
@sanketneema286 5 ай бұрын
Tushar is a saver, it looks like other KZbinrs also watch Tushar's videos to clear their doubts.
@Nikhil-ov6sm
@Nikhil-ov6sm Жыл бұрын
ok this is one of the few times where writing code is way more tougher than getting the logic..thanks btw great video
@satviktejas6085
@satviktejas6085 Жыл бұрын
One of the best explanation available on internet
@shekhar3027
@shekhar3027 8 жыл бұрын
wow..!! Thanks alot Tushar..!! Your tutorials are always informative and are in detail. But the best part is that its easily explained and extremely easy to understand and implement... :)...
@saurabhsharma7123
@saurabhsharma7123 7 жыл бұрын
String Theory has always been a mystery for me until just now!Cannot thank you more !
@shreyjain51
@shreyjain51 4 жыл бұрын
This is not called "String Theory"!!! That is a branch of physics.
@genuineprofile6400
@genuineprofile6400 Жыл бұрын
It's still is a mystery to you and other physicists.
@aashutoshagrawal5239
@aashutoshagrawal5239 19 күн бұрын
Loved the explanation.. Thank you for the video.
@smartwork7098
@smartwork7098 Ай бұрын
Beautiful man. Edit: Beautiful explanation, man
@keilamartinez7394
@keilamartinez7394 4 жыл бұрын
Absolutely great! You made it very easy to understand the algorithm, thank you so much!!
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
+Tushar Roy -great explanation as usual , clearly shows how well you understand.
@omprakashsharma9767
@omprakashsharma9767 4 жыл бұрын
I always like your videos, to the point no time wasting.
@sanjeevacham2400
@sanjeevacham2400 8 жыл бұрын
Excellent Tushar , you done it again.
@AGENTxxFURY
@AGENTxxFURY 11 ай бұрын
Best explanation , awesome teacher !!!
@shubhamk840
@shubhamk840 4 жыл бұрын
best video tutorial amazing Mr. Tushar.
@abhisheksharma7056
@abhisheksharma7056 2 жыл бұрын
we can use even lps(longest prefix suffix) array of appended string to find out the index of matching
@shuangli5466
@shuangli5466 Жыл бұрын
excellent explaination, I understood it instantly
@KanagaveluSugumar
@KanagaveluSugumar 8 жыл бұрын
Wow! you have done a great job :) And is that reusing match count within the Z box is benefit will i get compare to brute force ?? if not how it is better than brute force ?
@marcolunardi3630
@marcolunardi3630 3 ай бұрын
Excelent video, helped a lot
@MrDirtzuke
@MrDirtzuke 3 ай бұрын
true
@udaysabbisetty9509
@udaysabbisetty9509 Жыл бұрын
Man!!!That's Amazing Explaination...Thank You:)
@pramodprajapati9166
@pramodprajapati9166 6 жыл бұрын
Great Job as Always. I did understood the Algorithm instantly, but struggled in the implementation. Can you give any tips to improve on the implementation part. Maybe something I need to do or something I might be doing wrong.
@tahanimachowdhury
@tahanimachowdhury 8 жыл бұрын
Thanks a ton :D Waiting for Aho - Corasick and Finite State Automation :D
@Shawn9081
@Shawn9081 8 жыл бұрын
8 months later im still alive but no video ;'{
@adhishmalviya2408
@adhishmalviya2408 4 жыл бұрын
4 years later, NO video
@muthojusaketh
@muthojusaketh 3 жыл бұрын
4yrs 10 months later, no video :(
@jotsinghbindra8317
@jotsinghbindra8317 4 ай бұрын
8years now still no video
@sgerodes
@sgerodes 6 жыл бұрын
Awesome explanation. Thank you very much
@vijay_lakra
@vijay_lakra 9 жыл бұрын
Very good explanation.Thanks Tushar.
@venkatnarasimha1317
@venkatnarasimha1317 8 жыл бұрын
Excellent tutorial. I have one question to ask. Why should we prepend the pattern to the string. Instead we can also compare while it is a different string
@shivampratapsingh2188
@shivampratapsingh2188 5 ай бұрын
Amazing explaination !!11
@savanmatariya7494
@savanmatariya7494 3 жыл бұрын
Well Explained!!, Keep it up
@quyenamba4556
@quyenamba4556 8 жыл бұрын
It's very helpful and easy to understand :D Thanks u so much
@ningwang8077
@ningwang8077 8 жыл бұрын
you help me a lot, hope you upload more videos and I will always follow your channel~
@ankitm511
@ankitm511 6 жыл бұрын
Nice explanation :) Very easy to understand compared to reading about it
@ketan_sahu
@ketan_sahu 3 жыл бұрын
Great explanation. Thanks!
@saqibmasood501
@saqibmasood501 3 ай бұрын
Nicely explained
@ScramblerUSA
@ScramblerUSA 8 жыл бұрын
Honestly, it's not right. When you copy the values from Z-box to Z-box, you make a comparison for every number to find out whether it falls beyond the right boundary or not. Why these comparisons are not accounted for?
@deepankarsingh7230
@deepankarsingh7230 8 жыл бұрын
I am also wondering why its not counted in this video. Probably if we count that too, it should not go beyond linear time. But what will be the proof of that??
@sundeepb
@sundeepb 8 жыл бұрын
Yes, they should be counted, but that still makes the algorithm in linear time because when it falls in the right bounds, we will just copy the count, saving multiple comparisons from the first time. When it is out of bounds, we are going beyond the Z box, making new comparisons.
@pramodprajapati9166
@pramodprajapati9166 6 жыл бұрын
I think you are confused here because of the while in the for loop. Watchout that the while comparison is known and withing the Bounds (i.e 0-Left and R to Length at most). So it will not be n^2 complexity. If the while comparison was from 0 to N then it will be n^2
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
+Tushar Roy - your explanation is great , but it would be really good if you can give some context about the algorithm , like how difficult it is , etc.
@sheetal831
@sheetal831 8 жыл бұрын
Thanks alot bro!!! Such a great explanation of the algorithm :)
@glaucoa.9214
@glaucoa.9214 3 жыл бұрын
Thanks alot Tushar..!!
@BenevolentKhalluudi
@BenevolentKhalluudi 8 жыл бұрын
Really great explanation. Thank you very much for the effort to explain it clearly!
@CryingMG
@CryingMG 9 жыл бұрын
Great tutorial as always. Good job!
@gandhijainamgunvantkumar6783
@gandhijainamgunvantkumar6783 2 жыл бұрын
Amazing explanation 😀
@ankitkumar-et8ew
@ankitkumar-et8ew 5 жыл бұрын
What happens if parent string is 'aaaaa' and we have to calculate the no. Of comparison then it should be 4+3+2+1 or we can say it is of the form n+n-1+n-2+....1 therefore it's complexity is On^2
@Nate-kw9by
@Nate-kw9by 7 ай бұрын
Great tutorial!
@aniketsriwastva6345
@aniketsriwastva6345 4 жыл бұрын
Great Explaination Sir
@srijonmuhtasim3669
@srijonmuhtasim3669 3 жыл бұрын
helped a lot to understand the concept
@fruith_
@fruith_ 2 жыл бұрын
Thankiu. Hope to wacth multiple matrix
@harshitgangwar1426
@harshitgangwar1426 4 жыл бұрын
Good Job Brother.
@cm30tanaykulkarni14
@cm30tanaykulkarni14 3 жыл бұрын
INFORMATIVE
@DeepakKumar-wu4dt
@DeepakKumar-wu4dt 4 жыл бұрын
Really Helpful . Thanks
@sarthakbansal1303
@sarthakbansal1303 4 жыл бұрын
Great explanation !!!
@ChinmayTerse
@ChinmayTerse 8 жыл бұрын
Minor issue at 11:48 shouldn't it be greater than or equal to 1? Great video though!
@pawantiwary2043
@pawantiwary2043 8 жыл бұрын
what is the condition used at this timestamp? I did not understand. Could you please exlain?
@pranaykanjolia9077
@pranaykanjolia9077 4 жыл бұрын
Yaa, it should be greater than or equal to 1
@nwanzefranklin7777
@nwanzefranklin7777 9 жыл бұрын
thanks a lot tushar, it really helped
@jithinbabu6902
@jithinbabu6902 4 жыл бұрын
Thank you for the great explanation. I have one doubt though. We can do this algorithm even without $ right?
@francineidesilva5310
@francineidesilva5310 4 жыл бұрын
vhx.n ,o
@madhankumar8463
@madhankumar8463 2 жыл бұрын
No, there is a chance that the pattern maybe formed when we join the pattern and string.
@ninhtrinh8536
@ninhtrinh8536 3 жыл бұрын
Thank you very much !
@dineshkumar-kz3nc
@dineshkumar-kz3nc 4 жыл бұрын
good explation of algorithm and code both. Generally doesn't find the code explanation easily so good job. I guess all u need to improve that use something much digital and clear then this white board that's all.
@kaal_bhairav_24
@kaal_bhairav_24 4 жыл бұрын
13:24 here we go digital
@dronelektron
@dronelektron 9 жыл бұрын
As always great
@KittyMaheshwari
@KittyMaheshwari 2 жыл бұрын
Excellent!
@saurabhv1
@saurabhv1 8 жыл бұрын
What if the main string can consist of any utf8 character ? How to choose a special character in such a case ?
@biboswanroy6699
@biboswanroy6699 4 жыл бұрын
I'm your fan now
@edelfrefloresmamani4562
@edelfrefloresmamani4562 4 жыл бұрын
nice explanation :)
@singhalvikash
@singhalvikash 7 жыл бұрын
Hey Tushar , Great videos and explanation . Keep up the good work ! Do you have a video tutorial created for Sliding Window algorithm as well ?
@imyashdeepsharma
@imyashdeepsharma 9 жыл бұрын
Awesome algorithm sir :)
@imyashdeepsharma
@imyashdeepsharma 9 жыл бұрын
+Tushar Roy Please post LCA Queries sir
@prashantkaushal4057
@prashantkaushal4057 Жыл бұрын
at 21:04 time it will go the if condition because k is not greater than right but it is equal to right
@sauravsingh7216
@sauravsingh7216 4 жыл бұрын
Awesome bro.....,
@vedicdutta2856
@vedicdutta2856 4 ай бұрын
Awesome!
@durgeshdeep2544
@durgeshdeep2544 9 жыл бұрын
Thanks Tushar
@edwardnjoroge5222
@edwardnjoroge5222 3 жыл бұрын
You rock! Thank you!
@ranganroy8494
@ranganroy8494 3 жыл бұрын
on 11:16 when on index 13 the value of the Z array is 5, then 13+15 is crossing our Z box by 1 index. So, why we are not recalculating it again?
@ranganroy8494
@ranganroy8494 3 жыл бұрын
It will be great if anyone could help me out with this.
@anurag6219
@anurag6219 2 жыл бұрын
AHHH NICE EXPLANATIONS !!!!!
@martokalinov3733
@martokalinov3733 Жыл бұрын
Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:)
@juzhengzhang3059
@juzhengzhang3059 3 жыл бұрын
Should Z[0] = the length of original string?
@Kupo3.0
@Kupo3.0 Жыл бұрын
Thank you!
@gal1l1l-f7c
@gal1l1l-f7c 9 жыл бұрын
Thanks Tushar, great video! :) Can you explain Aho-Corasick in another one?
@grev7794
@grev7794 7 жыл бұрын
thank you :) very helpful
@timothyfield6190
@timothyfield6190 8 жыл бұрын
Very Helpful! Thank you.
@bishyankar2388
@bishyankar2388 8 жыл бұрын
Scanner sc=new Scanner(System.in); String s=sc.next(); String s1=sc.next(); int i; for(i=0;i
@bishyankar2388
@bishyankar2388 8 жыл бұрын
i tried it codechef
@bishyankar2388
@bishyankar2388 8 жыл бұрын
how are you calculating the time complexity
@bishyankar2388
@bishyankar2388 8 жыл бұрын
mine
@elllot_
@elllot_ 7 жыл бұрын
You do realize this is a O(m*n) (O(m*(n-m) to be exact) comparison where m is the length of the pattern and n is the length of the string algorithm compared to Z algorithm's O(n) complexity right? You're doing a comparison for the full pattern at each index. I do not buy your statement that this performed better than the Z algorithm. I think you should double check your implementation of the Z algorithm
@mohit7717
@mohit7717 2 жыл бұрын
For user input how i will know that special character are not exist in the input given by user ? How can we solve this problem
@omaryasser2308
@omaryasser2308 8 жыл бұрын
Thank you very much. :)
@subtlechords
@subtlechords 3 жыл бұрын
Thankyou so much
@markjethropacheco4546
@markjethropacheco4546 4 ай бұрын
I don`t understand the O(m+n) part. I don`t understand its purpose.
@Vicky-pu5fw
@Vicky-pu5fw 8 жыл бұрын
sir please upload video of TRIE/ Prefix tree
@gigelfranaru
@gigelfranaru 7 жыл бұрын
But why not just use a for that goes along the main text and looks for the pattern chars in sequence, and when a mismatch occurs, reset the index of where to look into in the pattern string. Why do all this work ?
@danielmitre
@danielmitre 7 жыл бұрын
The index you are in the sequence have to reset to previous+1, so it is O(n²) time complexity
@pawantiwary2043
@pawantiwary2043 8 жыл бұрын
Thanks for this video but I did not understand at 11:48...Could you (or any one)please explain this condition?
@mishramadhur
@mishramadhur 8 жыл бұрын
At this time stamp, we are at index 17 now since this character is in Z-box(notation used in video) we want to take its value from the previous position i.e from index 4, if we take its value 4 from the previous index(4), it means that a prefix of length 4 of the original string matches the suffix starting at index 17, but since the total length of string is only 18, the value can't be 4, since the suffix starting at index 17 can be of length 1 only. Hence the value is min(prev_value_taken, remaining length) i.e min(4, 18-17) = 1. Hope it helps
@mujahidansorimajid1524
@mujahidansorimajid1524 3 жыл бұрын
what if my pattern or my text the '$' exist will the code still work fine?
@lonandon
@lonandon 3 жыл бұрын
When to use Z Algorithm and when to use KMP?
@sarwarjahan05
@sarwarjahan05 8 жыл бұрын
Can i make table like kmp for z (pattern+$+text)?
@rohitraj4394
@rohitraj4394 5 жыл бұрын
how you will compute Z Array for Pattern P = caca and String = cacacacacacacacacaca. Please explain.
@hAsH_learn2code
@hAsH_learn2code 3 жыл бұрын
Thank you
@shreyjain51
@shreyjain51 4 жыл бұрын
He made a mistake at 10:04. It is not 17, it is 16.
@Inotaku
@Inotaku 3 жыл бұрын
why we need the line right--; ?
@somesome1315
@somesome1315 3 жыл бұрын
helpful thx
@SNM_23745
@SNM_23745 3 жыл бұрын
thank you
@fruith_
@fruith_ 2 жыл бұрын
Hope you reply, but if it's not, it's okay
@rahukdubey8138
@rahukdubey8138 3 жыл бұрын
while watching this video my brother (small haldi bilauwa) was beating me
@yuvraj2038
@yuvraj2038 2 жыл бұрын
Who is here after today's Leetcode contest?
@ritikbansal4851
@ritikbansal4851 4 жыл бұрын
Can anyone explain to me why do we do right - - in calculatez function. Thanks in advance
@nareshupadhyay1192
@nareshupadhyay1192 4 жыл бұрын
Solution by this method.?? Pattern :aa Text :aaaaaaaaaa
@ep.jonnadula
@ep.jonnadula 8 жыл бұрын
plz speak at normal speed at starting of video.every thing else is too good
@jesperat
@jesperat 5 жыл бұрын
he sounds really angry.
Longest Palindromic Substring Manacher's Algorithm
16:46
Tushar Roy - Coding Made Simple
Рет қаралды 338 М.
9.1 Knuth-Morris-Pratt KMP String Matching Algorithm
18:56
Abdul Bari
Рет қаралды 1,6 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 30 МЛН
黑的奸计得逞 #古风
00:24
Black and white double fury
Рет қаралды 20 МЛН
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 120 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 470 М.
Knuth-Morris-Pratt(KMP) Pattern Matching(Substring search)
12:50
Tushar Roy - Coding Made Simple
Рет қаралды 1,1 МЛН
АиСД S03E10. Z-функция. Бор
1:28:34
Pavel Mavrin
Рет қаралды 5 М.
16. Strings
1:24:30
MIT OpenCourseWare
Рет қаралды 125 М.
Manacher's Algorithm | Longest Palindromic Substring
21:47
Fluent Algorithms
Рет қаралды 29 М.
Z algorithm illustration
12:50
Code_with_Engineer
Рет қаралды 7 М.
Skyline Problem
22:54
Tushar Roy - Coding Made Simple
Рет қаралды 193 М.
9.2 Rabin-Karp String Matching Algorithm
23:50
Abdul Bari
Рет қаралды 792 М.
Lambda Calculus - Computerphile
12:40
Computerphile
Рет қаралды 1 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 30 МЛН