Symbols of String Pattern Matching in Introduction to Algorithms.

As it's important to be clear when discussing the problem of string matching, we can use the meticulous symbols used in Introduction to Algorithms.

Text:    $T[1, ..., n]$.

Pattern:  $P[1, ..., m]$.

Thus, as $T[i], P[j] \in \Sigma$, the array of letters, like $T[1, ..., n]$ or $P[1, ..., m]$, is called string.

Alphabet:  $\Sigma$.

Set of all finite length of strings:  $\Sigma^*$.

Define the empty string $\epsilon$, as it is a string, we also have $\epsilon \in \Sigma^*$.

Shifting $s$ matching:  $T[s+1, s+2, ..., s+m] = P[1, 2, ..., m]$.

$\omega$ is the prefix of string x:  Existing a string $y\in \Sigma^*$, such that $x=\omega y$, marked as $\omega \sqsubset x$.

$\omega$ is the suffix of string x:  Existing a string $y\in \Sigma^*$, such that $x=y \omega$, marked as $\omega \sqsupset x$.

Define $P_k$ as the prefix $P[1, ..., k]$ of string $P[1, ..., m]$. Thus we have: $P_0 = \epsilon, P_m = P = P[1, ..., m]$.

Based on the above symbols, the matching problem can be restated as:

Finding all the possible shifting values $s$, such that $P \sqsupset T_{m+s}$.

Symbols of String Pattern Matching的更多相关文章

  1. KMP string pattern matching

    The function used here is from the leetcode. Details can be found in leetcode problem: Implement str ...

  2. Beginning Scala study note(5) Pattern Matching

    The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters ...

  3. scala pattern matching

    scala语言的一大重要特性之一就是模式匹配.在我看来,这个怎么看都很像java语言中的switch语句,但是,这个仅仅只是像(因为有case关键字),他们毕竟是不同的东西,switch在java中, ...

  4. [PureScript] Break up Expressions into Cases in PureScript using Simple Pattern Matching

    Pattern matching in functional programming languages is a way to break up expressions into individua ...

  5. [Scala] Pattern Matching(模式匹配)

    Scala中的match, 比起以往使用的switch-case有著更強大的功能, 1. 傳統方法 def toYesOrNo(choice: Int): String = choice match ...

  6. pattern matching is C# 7.0

    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is 原来的版本 private static s ...

  7. C#9.0 终于来了,带你一起解读Pattern matching 和 nint 两大新特性玩法

    一:背景 1. 讲故事 上一篇跟大家聊到了Target-typed new 和 Lambda discard parameters,看博客园和公号里的阅读量都达到了新高,甚是欣慰,不管大家对新特性是多 ...

  8. Zhu-Takaoka Two-dimensional Pattern Matching

    Two dimensional pattern matching. Details may be added later.... Corresponding more work can be foun ...

  9. TypeError: cannot use a string pattern on a bytes-like object的解决办法

    #!/usr/python3 import re import urllib.request def gethtml(url): page=urllib.request.urlopen(url) ht ...

随机推荐

  1. flash项目优化总结

    swc中的类如果没有在项目中没有被申明,在编译时就不会被编译进swf中,这样一些swc中的类和资源类如果不用了,只要不被声明就不会占用swf大小了.

  2. ArcEngine编写WebService

    开发环境:Windows7旗舰版64bit.VisualStudio2008 With SP1.ArcEngine10.0.NetFrameWork4.0.IIS7和C#开发语言. 背景:ArcEng ...

  3. AVL树模板

    ///AVL树模板 typedef struct Node ///树的节点 { int val,data; int h; ///以当前结点为根结点的数的高度 int bf; ///平衡因子(左子树高度 ...

  4. Segmetation fault你来的真不是时候

    问题是这样的,今天一个简单的C程序,用gcc编译成汇编语言后,本来想在里面改点东西,结果运行时就报了"Segmetation fault".它丫来的还真不是时候,刚好最近正好烦它呢 ...

  5. three.js 源码注释(三十九)Light/HemisphereLight.js 半球光、 自然光(天光效果)

    /*** * HemisphereLight类 是在场景中创建半球光,就是天光效果,经常用在室外,将各个位置的物体都照亮,室内的光线大多是方向性的, * 无论是窗口还是灯槽,用平面光很方便,室外用平面 ...

  6. mongodb+pycharm使用报错,无法往mongodb存文件

    1 mongodb必须在启用状态下,启用如下 C:/mongodb/bin>mongod --dbpath C:\mongodb\data\db 不能关闭cmd 2 其他问题,貌似在Connec ...

  7. 【转】 全世界最短的IE判定

    以前最短的IE判定借助于IE不支持垂直制表符的特性搞出来的. var ie = !+"\v1"; 仅仅需要7bytes!讲述外国人是如何把IE的判定从32 bytes一步步缩简成7 ...

  8. 解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"

    Hibernate使用SLF4J API记录日志,所以在Hibernate的lib中,不再提供Log4J的包,而大部分框架依然使用Log4J记录日志,这样导致了兼容性问题. 解决办法,两步: 一.在编 ...

  9. mysql 数据库问题com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

    本文转自:http://blog.csdn.net/zmzsoftware/article/details/6835604 MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc ...

  10. [2011山东ACM省赛] Sequence (动态规划)

    Sequence Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Given an integer number sequence ...