Skip to content

fix: make bad character shift effective in boyer_moore_search - #15043

Open
deepshekhardas wants to merge 1 commit into
TheAlgorithms:masterfrom
deepshekhardas:fix-14844-boyer-moore-shift
Open

fix: make bad character shift effective in boyer_moore_search#15043
deepshekhardas wants to merge 1 commit into
TheAlgorithms:masterfrom
deepshekhardas:fix-14844-boyer-moore-shift

Conversation

@deepshekhardas

Copy link
Copy Markdown

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add, change, or clarify documentation?

What does this implement/fix?

The bad-character shift was dead code: reassigning the or-loop variable i has no effect, so the algorithm degraded to brute-force O(nm). Rewrite as a while loop so the shift actually skips positions.

Additional comments?

None.

Fixes #14844

The for-loop variable reassignment had no effect; use a while loop so
the bad-character rule actually skips positions (O(n/m) not O(nm)).

Fixes TheAlgorithms#14844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Boyer-Moore bad character shift has no effect (for-loop variable reassignment)

1 participant