Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

KMP classic algorithm and unit tests #125

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

Merged
TheSTL merged 4 commits into knaxus:master from jonathanmcchesney:master
Oct 23, 2019
Merged

KMP classic algorithm and unit tests #125

TheSTL merged 4 commits into knaxus:master from jonathanmcchesney:master
Oct 23, 2019

Conversation

Copy link
Contributor

@jonathanmcchesney jonathanmcchesney commented Oct 21, 2019

Story: #124

Added KMP algorithm to classics folder, along with a series of unit tests to bring the file coverage up to 100%.
Updated file to keep in line with eslint rules.
Added comments and time complexity of the KMP pattern matching algorithm.
Added example use case in file preamble.

TheSTL reacted with hooray emoji
/* *
* The time complexity of KMP algorithm is O(n) in the worst case
* Example use case: Pattern = ABCABCACA Text = AAABCBAABCABCACACABBCA
* LPSArray = [ 0, 0, 0, 1, 2, 3, 4, 0, 1 ]
Copy link
Member

Choose a reason for hiding this comment

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

It should be LPSArray = [ 0, 1, 0, 0, 1, 0 ]

Copy link
Contributor Author

@jonathanmcchesney jonathanmcchesney Oct 23, 2019

Choose a reason for hiding this comment

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

Hi @TheSTL the pattern had been updated to ABCABCACA. I feel this is a more intuitive example. I believe [ 0, 0, 0, 1, 2, 3, 4, 0, 1 ] to be the correct LPS, if there are any more queries or amendments you would like to be made, I’ll updage the PR as appropriate. Cheers.

TheSTL reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I think this example is more understandable from previous one to compute LPS.

Copy link
Member

@TheSTL TheSTL left a comment

Choose a reason for hiding this comment

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

Thanks @jonathanmcchesney for PR 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@TheSTL TheSTL TheSTL approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /