-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Knuth-Morris algo readme #2948
Knuth-Morris algo readme #2948
Conversation
Plz review my Pr @singh-shreya6 @asha15 @raghav-dalmia @MastersAbh |
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this extra lines
|
||
|
||
|
||
**Components of Knuth-Morris Pratt algorithm** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't bold it. use h2 header ( ## )
@@ -0,0 +1,136 @@ | |||
## Knuth-Morris Pratt Algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep one #
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the extra lines
|
||
|
||
|
||
##### **Steps for Creating LPS Table** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the bold sign
keep only two #
5. If both are not matched then check the value of variable 'i'. If it is '0' then set LPS[j] = 0 and increment 'j' value by one, if it is not '0' then set i = LPS[i-1]. Step 3. | ||
6. Repeat above steps until all the values of LPS[] are filled. | ||
|
||
**ALGORITHM** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this as a h2 header
increase i by 1 | ||
done | ||
|
||
End |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the space at the beginning
|
||
**Output**: The location where patterns are found. | ||
|
||
**How The Knuth-Morris Pratt Algorithm Work?** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this as a h2 header
done the changes @asha15 maam |
5. If both are not matched then check the value of variable 'i'. If it is '0' then set LPS[j] = 0 and increment 'j' value by one, if it is not '0' then set i = LPS[i-1]. Step 3. | ||
6. Repeat above steps until all the values of LPS[] are filled. | ||
|
||
ALGORITHM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make this as a sub header
5. If both are not matched then check the value of variable 'i'. If it is '0' then set LPS[j] = 0 and increment 'j' value by one, if it is not '0' then set i = LPS[i-1]. Step 3. | ||
6. Repeat above steps until all the values of LPS[] are filled. | ||
|
||
ALGORITHM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make this as a sub header
1. Define a one dimensional array with the size equal to the length of the Pattern. (LPS[size]) | ||
2. Define variables i & j. Set i = 0, j = 1 and LPS[0] = 0. | ||
3. Compare the characters at Pattern[i] and Pattern[j]. | ||
4. If both are matched then set LPS[j] = i+1 and increment both i & j values by one. Go to Step 3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the same coding convention here also. Add space around +
|
||
Consider the following Text and Pattern | ||
|
||
Text : ABC ABCDAB ABCDABCDABDE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks different in actual view. It doesn't come center aligned.
|
||
Text: ABC ABCDAB ABCDABCDABDE | ||
|
||
Pattern: ABCDABD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line also looks different from others. Please have a look at actual view of read me
|
||
It also has a space complexity of O (m) because there’s some pre-processing involved. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add References here.
changes done changes changes
Pl review @asha15 @singh-shreya6 maam. I have done the changes. |
Fixes #2555
Checklist:
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
Changes proposed in this pull request:
Languages Used:
Files Added:
Thanks!