Question: The CYK algorithm can be described as bottom-up because it starts with the word and works up to the nonterminals. There is another method for

The CYK algorithm can be described as bottom-up because it starts with the word and works up to the nonterminals. There is another method for deciding membership that is top-down in nature. Create a table with one column for each nonterminal that appears in the grammar and n rows, where n is the length of the subject word. The entries for cell (i,j) are those words of length i that can be derived from the nonterminal, Nj' at the head of the column. The first row is filled based on the dead productions N → t. Subsequent rows are filled based on the productions N → N1N2. In the second row, cell (2, z) is filled with all the words of length 2 that are the product of a letter from cell (1,x) and a letter from cell (1, y) for each rule Nz → Nx Ny . In the third row, cell (3, z) is filled with the words that are products of a word from row 2 and a word from row 1 in either order as long as the grammar includes a rule that generates that product. In the fourth row, the words can be made in three ways; the product of a letter and a 3-letter word, the product of two 2-letter words, the product of a 3-letter word and a single letter. When the table is complete, check cell (n, S) to see if w is among the words derived from S. 

For each of the following grammar- word pairs, construct such a table to determine whether the word can be generated by that grammar:

(i)

SXY XXA | a | b YAY | a A-a w =

(ii)

babaa

(iii)

SXY XXA | a | b YAY | a A-a w = babaa

Step by Step Solution

3.33 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

S aS bS ababb S aS bS abb S aS bS ababab Explanation The first grammarword p... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related SQL Database Programming Questions!