Skip to content
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

Merged
merged 1 commit into from
May 31, 2020
Merged

Knuth-Morris algo readme #2948

merged 1 commit into from
May 31, 2020

Conversation

raksha009
Copy link
Contributor

Fixes #2555

Checklist:

  • 4 space indentation.
  • Coding conventions are followed.
  • Input is taken dynamically.
  • Sample Input / Output is added at the end of file.
  • Logic Documentation (Comments).
  • File names are correct.

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:

  • ADDED NEW FILE

Languages Used:

Files Added:

  • Knuth-Morris_Pratt_Algorithm_README.md

We're happy to help you get this ready -- don't be afraid to ask for help.

Thanks!

@raksha009
Copy link
Contributor Author

Plz review my Pr @singh-shreya6 @asha15 @raghav-dalmia @MastersAbh

Comment on lines 6 to 7


Copy link
Collaborator

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**
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep one #

Comment on lines 14 to 15


Copy link
Collaborator

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**
Copy link
Collaborator

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**
Copy link
Collaborator

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
Copy link
Collaborator

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?**
Copy link
Collaborator

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

@raksha009
Copy link
Contributor Author

done the changes @asha15 maam

@raksha009 raksha009 requested a review from asha15 May 30, 2020 07:34
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
Copy link
Collaborator

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
Copy link
Collaborator

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.
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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.


Copy link
Collaborator

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
@raksha009
Copy link
Contributor Author

Pl review @asha15 @singh-shreya6 maam. I have done the changes.

@asha15 asha15 dismissed singh-shreya6’s stale review May 31, 2020 16:36

Made the requested changes

@asha15 asha15 merged commit b0db722 into jainaman224:master May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Knuth Morris Prat Algorithm
3 participants