Content deleted Content added
Rephrasing introduction |
Rephrasing |
||
Line 1:
The '''Cocke-Younger-Kasami (CYK) algorithm''' (alternatively called CKY) determines whether a
[[string (computer science)|string]] can be generated by a given [[context-free grammar]] and, if so, how it can be generated. This is known as [[parsing]] the string. The algorithm
The standard version of CYK
The importance of the CYK algorithm stems
The worst case [[asymptotic]] time complexity of CYK is [[Big O notation|Θ]](n<sup>3</sup>), where ''n'' is the length of the parsed string. This makes it one of the most efficient (in those terms) algorithms for recognizing general context-free languages. Specialized and faster algorithms exist for certain subsets of the context-free languages.
==Standard form==
===As pseudocode===
▲The algorithm for the membership problem is as follows:
'''Let''' the input string consist of ''n'' letters, ''a''<sub>1</sub> ... ''a''<sub>''n''</sub>.
'''Let''' the grammar contain ''r'' terminal and nonterminal symbols ''R''<sub>1</sub> ... ''R''<sub>''r''</sub>.
Line 27 ⟶ 25:
'''Else''' string is not member of language
===
In informal terms, this algorithm considers every possible subsequence of the sequence of words and sets P[i,j,k] to be true if the subsequence of words starting from i of length j can be generated from R<sub>k</sub>. Once it has considered subsequences of length 1, it goes on to subsequences of length 2, and so on. For subsequences of length 2 and greater, it considers every possible partition of the subsequence into two parts, and checks to see if there is some production P → Q R such that Q matches the first part and R matches the second part. If so, it records P as matching the whole subsequence. Once this process is completed, the sentence is recognized by the grammar if the subsequence containing the entire sentence is matched by the start symbol.
|