Uh oh!
There was an error while loading. Please reload this page.
Divide and conquer Algorithms Issue#817 - #938
Merged
Merged
Conversation
Erfaniaa
suggested changes
Jul 2, 2019
Erfaniaa
left a comment
Member
There was a problem hiding this comment.
I tested the code and it's correct.
| def max_sum_from_start(array): | ||
| def max_cross_array_sum(array, left, mid, right): | ||
| def max_sub_array_sum(array, left, right): | ||
| """ | ||
| """ base case: |
| if left == right: | ||
| return array[right] | ||
| """ Recursion""" |
| return array[right] | ||
| """ Recursion""" | ||
Erfaniaa
suggested changes
Jul 2, 2019
Erfaniaa
left a comment
Member
There was a problem hiding this comment.
I tested this algorithm and it's correct.
| This algorithm tries to find the pattern in given text using Bad Character Heuristic method. | ||
| The bad-character rule considers the character in Text at which there is a mis-match. The next occurrence of that character to the left in Pattern is found, and a shift which brings that occurrence in line with the mismatched occurrence in Text is proposed. If the mismatched character does not occur to the left in Pattern, a shift is proposed that moves the entirety of Pattern past the point of mismatch | ||
| Complexity : O(n/m) |
| self.textLen, self.patLen = len(text), len(pattern) | ||
| def match_In_Pattern(self, char): | ||
| def misMatch_In_Text(self, currentPos): | ||
| return -1 | ||
| def bad_Character_Heuristic(self): | ||
| self.text, self.pattern = text, pattern | ||
| self.textLen, self.patLen = len(text), len(pattern) | ||
| def match_In_Pattern(self, char): |
Member
There was a problem hiding this comment.
Make all methods, functions and variable names lower-case.
| return -1 | ||
| def misMatch_In_Text(self, currentPos): |
Member
There was a problem hiding this comment.
Make all methods, functions and variable names lower-case.
| @@ -0,0 +1,74 @@ | |||
| """ | |||
| This algorithm tries to find the pattern in given text using Bad Character Heuristic method. | |||
| The bad-character rule considers the character in Text at which there is a mis-match. The next occurrence of that character to the left in Pattern is found, and a shift which brings that occurrence in line with the mismatched occurrence in Text is proposed. If the mismatched character does not occur to the left in Pattern, a shift is proposed that moves the entirety of Pattern past the point of mismatch | |||
Member
There was a problem hiding this comment.
Put a period at the end of the line.
Also, follow PEP8 rules. Makes your lines contain 70 characters or less.
https://www.python.org/dev/peps/pep-0008/
Don't have any long lines.
Erfaniaa
approved these changes
Jul 2, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
issue #817
created divide_and_conquer folder and added max_sub_array_sum.py