Description: Elimination of left factoring in the given grammar
For each nonterminal A find the longest prefix (alpha) common to two or more of its alternatives.If alpha is not equal epsilon,i.e..,there is a nontrivial common prefix,replace all the A productions
Aàalpha beta1|alpha beta2|…|alpha betan|gamma
where gamma
represents all alternatives that donot begin with alpha by
AàalphaA’|gamma
A’àbeta1|beta2|…..|betan
Here A’ is the new terminal..
Repeatedly apply this transformation until no two alternatives for a nonterminal have a common prefix.-Elimination of left factoring in the given grammar
For each nonterminal A find the longest prefix (alpha) common to two or more of its alternatives.If alpha is not equal epsilon,i.e..,there is a nontrivial common prefix,replace all the A productions
Aàalpha beta1|alpha beta2|…|alpha betan|gamma
where gamma
represents all alternatives that donot begin with alpha by
AàalphaA’|gamma
A’àbeta1|beta2|…..|betan
Here A’ is the new terminal..
Repeatedly apply this transformation until no two alternatives for a nonterminal have a common prefix. Platform: |
Size: 8192 |
Author:mahi |
Hits:
Description: 算法分析:将整个字符串反过来写在原字符串后面。中间用一个特殊的字符隔开,中间我用的是0,最后面我又加了一个字符1, 如果再加0 很可能会出错。(最后一个应该也可以不加),这样就把问题变为了求这个新的字符串的某两个后缀的最长公共前缀
注意:提供一组数据 zzzdzaadzzz 答案应该输出zzz,而如果不仔细的话程序可能会输入zdz,因为有可能答案前缀没有相邻,所这里就得加上一个循环判断处理。因为这个WA三次
-Algorithm analysis: the entire string in turn write back the original string. The middle separated by a special character, the middle I use 0, the last face I added a character one, if there is likely to be wrong 0. (The last one should also not), so put the problem into a request string of a new two longest common prefix suffix NOTE: to provide the answer should be a set of data zzzdzaadzzz output zzz, and if not careful, then procedures may enter zdz, because there may be no answer to the prefix is adjacent to the loop where a judge had to deal with. WA three times because of this Platform: |
Size: 1024 |
Author:hansen |
Hits:
Description: 运用扩展KMP算法求出某一字符串与另一字符串的所有最长公共前缀-KMP algorithm the extended use of a string with another string of all longest common prefix Platform: |
Size: 1024 |
Author:wrs |
Hits:
Description: This code shows you how to create a suffix array and how to use RMQ algorithm to get two suffix s longest common prefix. Platform: |
Size: 2048 |
Author:lkq |
Hits:
Description: 设集合S由若干单词(英文)组成,给定字符串K,在S中查找与K最佳匹配的结果。最佳匹配的结果定义为:与K有最长共同前缀的字符串。
例:S={abc, bdef, zhen, zhao, abdd},K1=zhao,K2=abdf,K3=cheng,则与K1最匹配的结果是zhao,与K2最匹配的结果是abdd,与K3最匹配的结果是ε(空串)。
-Set the set S consists of several words (in English), with the given string K, and K to find the best match results in S. The results define the best match for: longest string and K have a common prefix. Example: S = {abc, bdef, zhen, zhao, abdd}, K1 = zhao, K2 = abdf, K3 = cheng, K1 is the best match and the result is zhao, and K2 is the best match abdd, and K3 most result of the matching is ε (the empty string). Platform: |
Size: 1024 |
Author:jiegenghua |
Hits:
Description: 字典树设集合S由若干单词(英文)组成,给定字符串K,在S中查找与K最佳匹配的结果。最佳匹配的结果定义为:与K有最长共同前缀的字符串。
例:S={abc, bdef, zhen, zhao, abdd},K1=zhao,K2=abdf,K3=cheng,则与K1最匹配的结果是zhao,与K2最匹配的结果是abdd,与K3最匹配的结果是ε(空串)。
-Dictionary tree set S by a number of words (English), given the string K, in the S to find the best match results K. The result of the best matching is defined as the string of the longest common prefix with K.
Cases: S={abc, bdef, Zhen, Zhao, abdd}, K1=zhao, K2=abdf, K3=cheng, and K1 the matching result is Zhao, K2 and the matching result is abdd, K3 and the matching result is epsilon (empty string). Platform: |
Size: 685056 |
Author:yyy |
Hits: