diff options
| author | akiyamn | 2021-03-18 15:06:37 +1100 |
|---|---|---|
| committer | akiyamn | 2021-03-18 15:06:37 +1100 |
| commit | 0dfa5353c274deb9aa455475965cf060e8ce4bd9 (patch) | |
| tree | d8885240bafcde4e5c3767273df98836e21d83a9 /w2/w2lect.md | |
| parent | 527ce5065ae429643433fac3435aeaa8f535e7c1 (diff) | |
| download | fit3155-0dfa5353c274deb9aa455475965cf060e8ce4bd9.tar.gz fit3155-0dfa5353c274deb9aa455475965cf060e8ce4bd9.zip | |
Start of ass1
Diffstat (limited to 'w2/w2lect.md')
| -rw-r--r-- | w2/w2lect.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/w2/w2lect.md b/w2/w2lect.md new file mode 100644 index 0000000..3fee16a --- /dev/null +++ b/w2/w2lect.md @@ -0,0 +1,30 @@ +# Boyer-Moore + +## Bad character rule: + +Shift pattern along to the left to the right-most version of the bad character +$O(m+n)$ *mostly* + +## Extended bad character rule +- 2D array for each char and each position in the pattern +- **Reduces naive shifts (i.e. by 1 to the right) but takes more space** + - Could use linked lists or something but that takes more time + +## Good suffix rule +**Makes Boyer-Moore worst case *almost* linear time rather than squared time** +- A suffix before the bad character that you know matches the text +- character to the left of the next instance of the good suffix must be different to the one to the left of the original suffix +- Move pattern along to the right to the point where the next suffix in the pattern matches + +## Galil's optimization +Improves on good suffix rules +**Actually linear time** +extended just makes it slightly faster and doesn't change the complexity + +# KNP +- $O(m+n)$ +- Easier to write, simpler +- Slower in practise than Boyer-Moore +- If mismatched first charatcer, move left by 1 (not covered by slides) +- Use Galil's on this too +- Proof is examinable (BM isn't) |
