Symbols of String Pattern Matching
2015-04-02 10:43
183 查看
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}$.
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}$.
相关文章推荐
- Matching Portions of A String to Elements of an Array in Ruby
- Generating a string with elements from an array based on pattern matching
- Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e
- KMP string pattern matching
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx': no matching editors or conversion strategy found
- Delphi的字符(Char), 字符串(String), 字符串指针( PChar ), 字符数组 array of char
- Value of type java.lang.String cannot be converted to JSONObject
- Three ways of implementing the Singleton Pattern in Java
- 职责链模式(Chain of Responsibility Pattern)
- 一劳永逸解决:TypeError: cannot use a string pattern on a bytes-like object
- String.IndexOf 方法(C#)
- leetcode :Reverse Vowels of a String
- 深入浅出设计模式——职责链模式(Chain of Responsibility Pattern)
- Inversion of Control Containers and the Dependency Injection pattern
- 模仿String.indexOf,判断一个字符串是否包含另一个字符串
- LeetCode--No.345--Reverse Vowels of a String
- Binary String Matching
- WEEK3-Lists and pattern matching
- Invalid layout of java.lang.String at value
- Inversion of Control Containers and the Dependency Injection pattern