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. oracle 创建数据表空间和用户

    --创建临时表空间(不必须)create temporary tablespace zwtest tempfile 'D:\Java\oracle\oradata\zwtest.dbf' size 5 ...

  2. AngularJS学习--- AngularJS中模板链接和图像 ng-src step6

    接上一篇文章,本文将主要介绍angularjs中的模板链接,和图像显示? 首先,切换分支,启动项目: git checkout step- npm start 1.效果 相较于前一篇文章,明显感觉多了 ...

  3. instr函数

    在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置. 语法如下:instr( string1, string2 [, start_position [, nth_appe ...

  4. 解决winrar压缩软件弹出广告

    最近winrar每次打开压缩包就会弹出一个广告,那是因为winrar是收费软件,注册了就没有广告了.下面我教大家怎么注册来屏蔽广告. 解决方法 1.新建一个txt文件并命名为"rarreg. ...

  5. 使用 BeanCopier 复制对象

    Cglib是一款比较底层的操作java字节码的框架. BeanCopier是一个工具类,可以用于Bean对象内容的复制. 复制Bean对象内容的方法有很多,比如自己手动get set ,或者使用Pro ...

  6. 子元素的div不继承父元素的透明度

    问题一: 如何让logo部变成这样: 步骤一:先收一个大的div,上面logo+nav再一个div,下面是三个div横排着: 步骤二:最主要的是如何让上面的部分变暗,而logo的颜色不变暗? 答案:在 ...

  7. python 迭代器和生成器

    1.迭代器协议是指:对象必须提供一个next方法,执行该方法要么返回迭代中的下一项,要么就引起一个StopIteration异常,以终止迭代 (只能往后走不能往前退)2.可迭代对象:实现了迭代器协议的 ...

  8. mybatis 控制台打印sql

    开发时调试使用 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBe ...

  9. 传统MySQL+ Memcached架构遇到的问题

    实际MySQL是适合进行海量数据存储的,通过Memcached将热点数据加载到cache,加速访问,很多公司都曾经使用过这样的架构,但随着业务数据量的不断增加,和访问量的持续增长,我们遇到了很多问题: ...

  10. Round函数

    Round():函数返回一个数值,舍入到指定的长度或精度 eg: --1) ) ---->123.9990 ) ---->124.0000 --3为需要舍入的位数 --2) ) ----- ...