stringmatching

package
v0.0.0-...-d229d73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KnuthMorrisPratt

func KnuthMorrisPratt(s, txt string) bool

Knuth-Morris-Pratt 字符串匹配算法(即 KMP 算法) http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html

func Naive

func Naive(s, txt string) bool

朴素的字符串匹配算法(Naive String Matching Algorithm)

朴素的字符串匹配算法又称为暴力匹配算法(Brute Force Algorithm),它的主要特点是:

  1. 没有预处理阶段;
  2. 滑动窗口总是后移 1 位;
  3. 对模式中的字符的比较顺序不限定,可以从前到后,也可以从后到前;
  4. 匹配阶段需要 O((n - m + 1)m) 的时间复杂度;
  5. 需要 2n 次的字符比较;

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL